Explain the data structure you would use to implement pop() and push(Object, int) for a Priority Queue.
Anonymous
Heap is the one to choose. Priority queue always pops out the highest valued element(the highest value is defined using weak ordering criterion), pop_heap will make sure the second highest element is placed on top after the first one is popped out, push_heap will also make sure the highest value is placed on top of the queue. In many cases, this is all you want - the highest valued element, which is what priority queue is operating on..
Check out your Company Bowl for anonymous work chats.