GATE IT 2004 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0228

An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node \(\left \lfloor (n - 1) /2 \right \rfloor\), and doing this adjustment up to the root node (root node is at index 0) in the order \(\left \lfloor (n - 1) /2 \right \rfloor\),\(\left \lfloor (n - 3) /2 \right \rfloor\), ....., 0. The time required to construct a heap in this manner is
  1. A
    \(O(\log n)\)
  2. B
    O(n)
  3. C
    \(O (n \log \log n)\)
  4. D
    \(O(n \log n)\)

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option B.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/3696/gate2004-it-53

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com