CSC301: Trees: Terminology [30/56] |
A root is a node with no ancestors.
A leaf is a node with no descendants.
Note that in a singleton tree (tree with one node), the root is also a leaf.
The size of a node is the number descendants (including itself).
A leaf node will have a size of 1.
The size of a tree is the size of its root. Empty tree has size of 0.
The height of a node is the number of edges on the longest path from the node to a leaf.
A leaf node will have a height of 0.
The height of tree is the height of its root. Empty tree has height of -1.
The depth of a node is the number of edges from the tree's root to the node.
A root node will have a depth of 0.
The depth of a tree is the same as it's height.