algorithm remove(value prevalue is the value to remove from the heap lef tand right are updated aliasfor index and index respectively count is the number of items in the heap heap is the array used to store the heap items postvalue is located in the heap and removedtrueotherwise false /step index findindex(heapvalue if index return false end if count count - /step heap[indexheap[count /step while lef heap[lef tor heap[indexheap[right /promote smallest key from subtree if heap[lef theap[right swap(heaplef tindex index lef else swap(heaprightindex index right end if end while return true end remove figure shows the remove algorithm visuallyremoving from heap containing the values and in figure you can assume that we have specified that the backing array of the heap should have an initial capacity of eight please note that in our deletion algorithm that we don' default the removed value in the heap array if you are using heap for reference typesi objects that are allocated on heap you will want to free that memory this is important in both unmanagedand managed languages in the latter we will want to null that empty hole so that the garbage collector can reclaim that memory if we were to not null that hole then the object could still be reached and thus won' be garbage collected searching searching heap is merely matter of traversing the items in the heap array sequentiallyso this operation has run time complexity of (nthe search can be thought of as one that uses breadth first traversal as defined in ss to visit the nodes within the heap to check for the presence of specified item