Trees in Discrete Structure
Trees in Discrete Structure
□ Node height - the length of the longest path from the node to some
leaf
□ The height of any leaf node is 0
□ The height of node 8 is 1
□ The height of node 1 is 3
□ The height of node 11 is 0
Tree height
□ The height of the root of the tree, or
□ The number of levels of a tree -1.
□ The height of the given tree is 3.
Problems:
□ Cycles: there is a cycle in the tree
□ Multiple parents: node 3 has multiple parents on different levels
Binary tree - a tree where every node has at most two children
□ All nodes rooted at the left child are smaller than the current node
value
□ All nodes rooted at the right child are smaller than the current node
value