Skip to content
GATEiit

GATE CSE 2023 Q46: Worst-case Extract-Max and Insert on a max-heap

Question

Let AA be a priority queue for maintaining a set of elements. Suppose AA is implemented using a max-heap data structure. The operation Extract-Max(AA) extracts and deletes the maximum element from AA. The operation Insert(AA, key) inserts a new element key in AA. The properties of a max-heap are preserved at the end of each of these operations.

When AA contains nn elements, which one of the following statements about the worst case running time of these two operations is TRUE?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: B (official GATE 2023 final answer key)

Concept used: Heap operations restore the heap by moving one element along a root-to-leaf path of height log⁡n\log n.

First step: Note that Extract-Max must delete the root and re-heapify, not just read it.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2023 CS question paper and final answer key, organised by IIT Kanpur. Question paper · Answer key