priority queues (heapstemplate class binaryheap publicexplicit binaryheapint capacity )explicit binaryheapconst vector items )bool isemptyconstconst comparable findminconstvoid insertconst comparable )void insertcomparable & )void deletemin)void deletemincomparable minitem )void makeempty)privateint currentsizevector array/number of elements in heap /the heap array void buildheap)void percolatedownint hole )}figure class interface for priority queue for any element in array position ithe left child is in position ithe right child is in the cell after the left child ( )and the parent is in position / thusnot only are links not requiredbut the operations required to traverse the tree are extremely simple and likely to be very fast on most computers the only problem with this implementation is that an estimate of the maximum heap size is required in advancebut typically this is not problem (and we can resize if neededin figure the limit on the heap size is elements the array has position more on this later heap data structure willthenconsist of an array (of comparable objectsand an integer representing the current heap size figure shows priority queue interface throughout this we shall draw the heaps as treeswith the implication that an actual implementation will use simple arrays heap-order property the property that allows operations to be performed quickly is the heap-order property since we want to be able to find the minimum quicklyit makes sense that the smallest element should be at the root if we consider that any subtree should also be heapthen any node should be smaller than all of its descendants