17. Binary Tree: Adding nodes

Example: Adding nodes

The alphabetically sorted binary tree shown below has been formed

Question: Where would 'larry' and 'tom' be placed in the tree?

Answer: As shown below, the rule is 'larry' alphabetically comes after the root 'kevin' and so must be in the right sub tree, larry comes before sam and so must be in the left sub tree below it. Likewise, tom is also in the right sub-tree but comes after sam, so it must be in a right subtree. Like this

alphabetically sorted binary tree

 


     
 

Copyright © www.teach-ict.com