Consider a binary search tree with n nodes and height h where: . Every internal
ID: 3732582 • Letter: C
Question
Consider a binary search tree with n nodes and height h where: . Every internal node in the tree has exactly two children. (No nodes with only one child.) . For each internal tree node x, the heights of the subtrees rooted at r.left and a.right differ by at most 1 (a) Prove that if the subtree rooted at z has height h', then the heights of the subtrees rooted at r.left and x.right are at least h-2. (Note: One subtree must have height l'1 but the other could have (b) Using your answer to part a), prove that if the binary search tree has height h, then the length of (c) Using your answer to part b), prove that if the binary search tree has height h, then the tree has d) Using your answer to part c), prove that if the binary search tree has n nodes, then the tree has height h -1 or h'-2) the shortest path from the root to any leaf is at least [h/2 at least 2Ih/21+1 -1 nodes. height at most 2 logz(n+1).Explanation / Answer
Answer
given by
while mentioned in problem that binary search tree with n nodes and h height anywhere every node has exctly two kids so that it cab be either AVL tree or Red black tree. at this time AVL tree is very well balanced tree and the so as to is not mention so we can judge it as red black tree.
b) if the dual tree has hieght h then the through path for the root is h/2
we know that the time intricacy of BST is log2(n) that means each time while searching element or unserting element we rule out semi the space of the tree. since BSt is sorted hierarchy it means either the element which is beaing search either in left or precise side of the root node so what's more we rule out left tree or wrong tree on root. now the same will be perform at evevry node until the tree height do equal to 1.
so at every case part will get searched at h/2 until we reach at correct node of tree hight 1 ( or element not originate case )
so we can articulate inn every iteration we rule out the complete half of tree so we can articulate that the direct path for the root lump is h/2
C ) let reason we have n node in tree so we can say and each node has their left or precise node or we cna say evenhanded tree.
so we can inscribe next series and symbolize the tree
1 + 2 power(1) + 2power(2) + 2power(3) + ... + 2 power(h) = n
2 - 1 + 2 power(1) + 2power(2) + 2power(3) + ... + 2 power(h) = n
2 - 2 power ( h ) = n
2 power ( h - 1) = n
2 power (( h - 1) /2) = n
2 [ h / 2] + 1 - 1 = n
D) We know that moment complexity of binary search tree for investigate, insert and delete procedure is o(log n) followed by
The total numeral of nodes in the BST is equal to the sum of the wedded odes on all the level: nodes n.
1 + 2 power(1) + 2power(2) + 2power(3) + ... + 2 power(h) = n
2 power(h+1) - 1 = n
2 power ( h + 1) = n + 1
Taking together side
log2 ( h + 1) = log2 ( n + 1
(h + 1) log2 (power 2) = log2(n + 1
h + 1 = log2 ( n + 1 )
h = log2 ( n + 1 ) - 1
We can say the more than term is
h = log2 ( n) + constants
Constants can be unseen here so to conclude
h = log2(n
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.