data structures using in the worst caseinsertion of single value may take (log ntime andsimilarlyto build heap of elementsthe algorithm will execute in ( log ntime deleting an element from binary heap consider max heap having elements an element is always example consider the max deleted from the root of the heap sodeleting an element from heap shown in fig and delete the heap is done in the following three stepsthe root node' value replace the root node' value with the last node' value solution so that is still complete binary tree but not necessarily heap delete the last node sink down the new root node' value so that satisfies the heap property in this stepinterchange the root node' value with its child node' value (whichever is largest among its children herethe value of root node and the value of the last node soreplace with and delete the last node figure binary heap (step (step (step (step (since is less than interchange the values (since is less than interchange the valuesfigure binary heap after discussing the concept behind deleting the root element from the heaplet us look at the algorithm given in fig we assume that heap with elements is stored using sequential array called heap last is the last element in the heap and ptr left and right denote the step [remove the last node from the heapset last heap[ ]set position of last and its left and right children step [initializationrespectively as it moves down the heap set ptr left right step set heap[ptrlast step repeat steps to while left < step if heap[ptr>heap[leftand heap[ptr>heap[rightgo to step [end of ifstep if heap[right<heap[leftswap heap[ptr]heap[leftset ptr left else swap heap[ptr]heap[rightset ptr right [end of ifstep set left ptr and right left [end of loopstep return figure algorithm to delete the root element from max heap applications of binary heaps binary heaps are mainly applied for sorting an array using heapsort algorithm we will discuss heapsort algorithm in implementing priority queues binary heap implementation of priority queues in we learned about priority queues we have also seen how priority queues can be implemented using linked lists priority queue is similar to queue in which an item is