heap as priority queue we'll discuss briefly how these operations are carried out and then see them in action in workshop applet removal removal means removing the node with the maximum key this node is always the rootso removing it is easy the root is always at index of the heap arraymaxnode heaparray[ ]the problem is that once the root is gonethe tree is no longer completethere' an empty cell this "holemust be filled in we could shift all the elements in the array down one cellbut there' much faster approach here are the steps for removing the maximum node remove the root move the last node into the root trickle the last node down until it' below larger node and above smaller one the last node is the rightmost node in the lowest occupied level of the tree this corresponds to the last filled cell in the array (see the node at index with the value in figure to copy this node into the root is straightforwardheaparray[ heaparray[ - ] --the removal of the root decreases the size of the array by one to trickle (the terms bubble or percolate are also useda node up or down means to move it along path step by stepswapping it with the node ahead of itchecking at each step to see whether it' in its proper position in step the node at the root is too small for that positionso it' trickled down the heap into its proper place we'll see the code for this later step restores the completeness characteristic of the heap (no holes)and step restores the heap condition (every node larger than its childrenthe removal process is shown in figure in part aof this figure the last node ( is copied to the rootwhich is removed in parts ) )and )the last node is trickled down to its appropriate positionwhich happens to be on the bottom row (this isn' always the casethe trickle-down process may stop at middle row as well part eshows the node in its correct position