GATE CS 2023 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0170

Let A be a priority queue for maintaining a set of elements. Suppose A is implemented using a max-heap data structure. The operation Extract-Max(A) extracts and deletes the maximum element from A. The operation Insert(A,key) inserts a new element key in A. The properties of a max-heap are preserved at the end of each of these operations.When A contains n elements, which one of the following statements about the worst case running time of these two operations is TRUE?
  1. A
    Both Extract-Max(A) and Insert(A,key) run in O(1).
  2. B
    Both Extract-Max(A) and Insert(A,key) run in O(log(n)).
  3. C
    Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(n).
  4. D
    Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(log(n)).

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionOfficial GATE Answer Key: Option B.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/399275/gate-cse-2023-question-36

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