previous | start | next

Priority Queue

What's wrong with this idea for a max priority queue?

To implement find the maximum in constant time, why not use a stack or a queue, but keep track of the maximum value inserted so far, then return that value for find the maximum.



previous | start | next