• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | CSE 2023 | Question 47

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?

(A)

Both EXTRACT-MAX(A) and INSERT(A,key) run in O(1).

(B)

Both EXTRACT-MAX(A) and INSERT(A,key) run in O(log(n)).

(C)

EXTRACT-MAX(A) runs in O(1) whereas INSERT(A,key) runs in O(n).

(D)

EXTRACT-MAX(A) runs in O(1) whereas INSERT(A,key) runs in O(log(n)).

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments