GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2023

GATE 2023 · CS · MCQ · 2 marks · Programming and Data Structures › Heaps

GATE 2023 Computer Science and Information Technology question: Let A be a priority queue for maintaining a set of elements. Suppose A is implemented…

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(,) inserts a new element 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?

  1. (A)

    Both EXTRACT-MAX() and INSERT(,) run in .

  2. (B)

    Both EXTRACT-MAX() and INSERT(,) run in .

  3. (C)

    EXTRACT-MAX() runs in whereas INSERT(,) runs in .

  4. (D)

    EXTRACT-MAX() runs in whereas INSERT(,) runs in .

Show answer

Official answer: B

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion