heaps in this introduction to heaps java code for heaps tree-based heap we saw in "stacks and queues,that priority queue is data structure that offers convenient access to the data item with the smallest (or largestkey priority queues may be used for task scheduling in computerswhere some programs and activities should be executed sooner than others and are therefore given higher priority another example is in weapons systemssay in navy cruiser numerous threats--airplanesmissilessubmarinesand so on--are detected and must be prioritized for examplea missile that' short distance from the cruiser is assigned higher priority than an aircraft long distance away so that countermeasures (surface-to-air missilesfor examplecan deal with it first priority queues are also used internally in other computer algorithms in "weighted graphs,we'll see priority queues used in graph algorithmssuch as dijkstra' algorithm priority queue is an abstract data type (adtoffering methods that allow removal of the item with the maximum (or minimumkey valueinsertionand sometimes other operations as with other adtspriority queues can be implemented using variety of underlying structures in we saw priority queue implemented as an ordered array the trouble with that approach is thateven though removal of the largest item is accomplished in fast ( timeinsertion requires slow (ntimebecause an average of half the items in the array must be moved to insert the new one in order heapsort