In computer science, a tree is an abstract model of a non-linear hierarchical structure, it consists of nodes with a parent-child relation.
Each node except for the root, has a parent and zero or more children.
Root: node without parent
Internal node: node with at least one child
External node: node without children
Ancestors of a node: parent, grandparent, grand-grandparent
Descendant of a node: child, grandchild, grand-grandchild
Siblings: children of the same parent
Depth of a node: number of ancestors
Height of a tree: maximum depth of any node
Sub-tree: tree consisting of a node and its descendants
Formal Tree Definition
Tree T is a set of nodes storing elements such that the nodes have a parent-child relationship, that satisfies the following properties:
if T is non-empty, it has a special node, called the root of T that has no parent
each node v of T different from the root has a unique parent node w
every node with parent w is a child of w
Ordered Tree
Ordered Tree
A tree is ordered if there is a linear ordering defined for the children of each node. We can identify the children of node as being the first, second, third, etc.
Ordered trees typically indicate the linear order among siblings by listing them in the correct order.