1,462 views
2 votes
2 votes
Consider the avl tree T in which left subtree contain quarter of the maximum number of nodes possible in the balanced AVL  tree of height  h and right sub tree consist of one fifth of the maximum number of nodes possible in AVL tree of height h. Assume that tree T may or may not be height balanced at parent.what is the total maximum possible number of nodes in T.

1 Answer

Best answer
3 votes
3 votes

AVL tree is balanced binary search tree.

so maximum no of nodes at height 'h' is $2^{h+1}-1$

 Left subtree contains quarter of max no of nodes at height 'h' =$\frac{2^{h+1}-1}{4}$.

Right subtree contains on fifth of max nof nodes at height 'h' is=$\frac{2^{h+1}-1}{5}$.

Finally total no of nodes in AVL tree is=sum of nodes at left subtree+sum of nodes at right subtree+1.

=$\frac{2^{h+1}-1}{4}$.+$\frac{2^{h+1}-1}{5}$.+1

=.$\frac{9*2^{h+1}+11}{20}$

selected by

No related questions found