2,678 views
1 votes
1 votes
What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l

 

2 Answers

1 votes
1 votes
Assuming root at height 1

Since maximum elements in a tree (complete binary tree) of height l will be (2^l)-1 so a good array size must be that (since a binary tree node may not always have 2 children but for safety we should take it).

Therefore, none of your answer is correct it should be (2^l) -1
edited by
1 votes
1 votes
Answer will be $2^{l}-1$ if you consider the array indexing starting from 1

At height l=1--$2^1-1$ only one node

l=2  -- $2^2-1$node

At l height max node will be $2^l-1$

So this is max size of array that would be required

Related questions

0 votes
0 votes
0 answers
1
Na462 asked Oct 20, 2018
627 views
Consider 4 labeled 1,2,3,4. The number of distinct binary tree possible such that whose inorder traversal is 1,2,3,4 are ........
1 votes
1 votes
1 answer
2
pradeepchaudhary asked Aug 19, 2018
19,151 views
8. What are the worst case and average case complexities of a binary search tree?a) O(n), O(n)b) O(logn), O(logn)c) O(logn), O(n)d) O(n), O(logn)