in Others retagged by
2,370 views
2 votes
2 votes

When the priority queue is represented by max heap, the insertion and deletion of an element can be performed in (queue containing $n$ elements)

  1. $\theta(n)$ and $\theta(1)$ respectively
  2. $\theta(n)$ and $\theta(n)$ respectively
  3. $\theta(1)$ and $\theta(1)$ respectively
  4. None of the above
in Others retagged by
2.4k views

2 Answers

4 votes
4 votes
Best answer
D is answer

Inserting Element take O(logn ) in worst case.(insert at least then find its correct possition)

Deletion Element take O(logn ) in worst case.( 1st we have to search that element)
selected by
0 votes
0 votes

Ans: D
We can use heaps to implement the priority queue. It will take O(log N) time to insert and delete each element in the priority queue.
ref: https://www.hackerearth.com/practice/notes/heaps-and-priority-queues/

Answer:

Related questions