Exams › GATE › Technical
We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is
- Θ(log n)
- Θ(n)
- Θ(n log n)
- Θ(n²)
Correct answer: Θ(n)
Solution
Inserting n elements not necessarily one-by-one means placing all 2n elements and running build-heap (heapify), which is Theta(n). So the total time is Theta(n).
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →