Computer Science EngineeringHard
The maximum number of nodes in a binary tree of height h (root at height 0) is
- A. 2^h - 1
- B. 2^(h+1) - 1
- C. 2^(h+1)
- D. 2^h + 1
Correct answer: B. 2^(h+1) - 1
Levels 0 to h hold 1+2+...+2^h = 2^(h+1) - 1 nodes.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The recurrence T(n) = 2T(n/2) + n log n solves to
- Consider int f(int n){ if(n<=1) return 1; return f(n-1)+f(n-2); }. What does f(6) return?
- Quicksort that always picks the first element as pivot runs in what time on an already sorted array?
- Dijkstra's algorithm using a binary heap and adjacency lists runs in
- For n a power of 2, what is the Theta bound of the loop: x=0; for(i=1;i<=n;i=2) for(j=0;j<i;j++) x++;
- How many leaf nodes does a binary heap stored in an array of 15 elements have?