heaps class priorityqueue private heap theheappublic void insert(node ndtheheap insert(nd)public node remove(return theheap remove(the methods for the priorityqueue class are simply wrapped around the methods for the underlying heap classthey have the same functionality this example makes it conceptually clear that priority queue is an adt that can be implemented in variety of wayswhile heap is more fundamental kind of data structure in this for simplicitywe'll simply show the heap' methods without the priorityqueue wrapping weakly ordered heap is weakly ordered compared with binary search treein which all node' left descendants have keys less than all its right descendants this impliesas we sawthat in binary search tree you can traverse the nodes in order by following simple algorithm in heaptraversing the nodes in order is difficult because the organizing principle (the heap conditionis not as strong as the organizing principle in tree all you can say about heap is thatalong every path from the root to leafthe nodes are arranged in descending order as you can see in figure the nodes to the left or right of given nodeor on higher or lower levels--provided they're not on the same path--can have keys larger or smaller than the node' key except where they share the same nodespaths are independent of each other because heaps are weakly orderedsome operations are difficult or impossible besides its failure to support traversala heap also does not allow convenient searching for specified key this is because there' not enough information to decide which of node' two children to pick in trying to descend to lower level during the search it follows that node with specified key can' be deletedat least in (logntimebecause there' no way to find it (these operations can be carried outby looking at every cell of the array in sequencebut this is only possible in slow (ntime thusthe organization of heap may seem dangerously close to randomness neverthelessthe ordering is just sufficient to allow fast removal of the maximum node and fast insertion of new nodes these operations are all that' needed to use