Binary Search Tree need some help understanding this observation

Revision en2, by vikalp14, 2018-08-01 22:07:33

If rules of creating BST is as follows:

The left sub-tree contains only nodes with values less than or equal to the parent node; the right sub-tree contains only nodes with values greater than the parent node.

If a node has level i, then the subtree rooted at that node should have exactly number of distinct values in the subtree. Note that it is the number of distinct values in the subtree and not the number of nodes in the subtree.

If a is the smallest value in the tree and b is the largest value, then all values from a to b must come atleast once in the tree.

It says that we can observe that, in subtree with N nodes, (N-1)/2 nodes will occur twice and 1 node will occur exactly once, which will be of maximum value, and tree will be of form: img

Can someone explain why is this so, or better yet point me to some resource which will help me understand this. #### History

Revisions Rev. Lang. By When Δ Comment
en2 vikalp14 2018-08-01 22:07:33 69
en1 vikalp14 2018-08-01 22:05:57 1167 Initial revision (published)