GATE CSE 2023 Q46: Worst-case Extract-Max and Insert on a max-heap
- Programming and Data Structures
- 2 marks
- MCQ
- −2/3 if wrong
Question
Let be a priority queue for maintaining a set of elements. Suppose is implemented using a max-heap data structure. The operation Extract-Max() extracts and deletes the maximum element from . The operation Insert(, key) inserts a new element key in . The properties of a max-heap are preserved at the end of each of these operations.
When contains 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
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 .
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
Source: official GATE 2023 CS question paper and final answer key, organised by IIT Kanpur. Question paper · Answer key
More Programming and Data Structures PYQs
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd
- 2026 Session 1 · Q24Empty slots after linear-probing inserts with h(x) = (x+7) mod 11
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..15