Consider the following statements about the heap sort algorithm:
A. The MAX-HEAPIFY procedure, which runs in O(lg n) time, is the key to maintaining the max-heap property.
B. The BUILD-MAX-HEAP procedure, which runs in O(lg n) time, produces a max-heap from an unordered input array.
C. The MAX-HEAP-INSERT procedure, which runs in O(lg n) time, implements the insertion operation.
D. The HEAP-INCREASE-KEY procedure runs in O(n lg n) time to set the key of a new node to its correct value.
Choose the correct answer from the options given below:
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. A, C only
Explanation
Per CLRS, MAX-HEAPIFY is O(lg n), BUILD-MAX-HEAP is O(n) (not O(lg n)), MAX-HEAP-INSERT is O(lg n) and HEAP-INCREASE-KEY is O(lg n). So A and C are true.More Data Structures and Algorithms questions
- Match List I with List IIList I List II A. Parallel FFT I. Θ(n²) B. Iterative FFT II. Θ(n) C. Evaluation of polynomial at n points by Horne…
- Let f(n) and g(n) be asymptotically positive functions. Statement I: f(n) ≥ 1 and f(n) = O(g(n)) ⇒ g(n) = Ω(f(n)). Statement II: f(n) = O(g…
- Consider the following statements: A. If some NP-complete problem is in P, then P = NP. B. TSP is in NP. C. SAT is in NP. D. The Hamiltonia…
- A B-tree used as an index for a large database table has four levels including the root node. If a new key is inserted into this index, the…
- Suppose a circular queue of capacity n − 1 elements is implemented with an array of n elements. Insertion and deletion use REAR and FRONT a…
- Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason R. Assertion A: AVL trees are more balan…