Computer Science EngineeringModerate
The time needed to build a binary heap from n arbitrary elements using bottom-up heapify is
- A. O(n)
- B. O(n log n)
- C. O(log n)
- D. O(n^2)
Correct answer: A. O(n)
The sum of sift-down costs over all levels converges to a linear bound, giving O(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 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
- 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++;