Answer to Question #246978 in Algorithms for Roy

Question #246978

Explain the use of the binary heap as an effective implementation for a priority queue .


1
Expert's answer
2021-10-05T13:23:39-0400

As the first element in the min-heap is always the smallest one the binary heap may be used as an implementation of a priority queue. The operation of adding an element to the priority queue is simply the operation of insertion into the heap (with the following reordering to keep heap property) and pulling is realised as removing the first element from the min-heap. As the time complexity of both, adding and removing to/from the heap is O(n log n), this implementation of the priority queue is very effective.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Roy
05.10.21, 23:48

I appreciate your support in solving questions,, Tnks and keep it up

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS