Computer Science EngineeringModerate
The height (in edges) of a complete binary tree having n nodes is
- A. ceil(log2 n)
- B. n/2
- C. floor(log2 n)
- D. n-1
Correct answer: C. floor(log2 n)
A complete binary tree fills levels in order, so its height is floor(log2 n).
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 time needed to build a binary heap from n arbitrary elements using bottom-up heapify is
- The maximum number of nodes in a binary tree of height h (root at height 0) is
- 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