data structures using sequentially in an array it follows the same rules as that of complete binary tree that isif an element is at position in the arraythen its left child is stored at position and its right child at position + converselyan element at position has its parent stored at position / being complete binary treeall the levels of the tree except the last level are completely filled the height of binary tree is given as log nwhere is the number of elements heaps (also known as partially ordered treesare very popular data structure for implementing priority queues binary heap is useful data structure in which elements can be added randomly but only the element with the highest value is removed in case of max heap and lowest value in case of min heap binary tree is an efficient data structurebut binary heap is more space efficient and simpler inserting new element in binary heap consider max heap with elements inserting new value into the heap is done in the following two steps add the new value at the bottom of in such way that is still complete binary tree but not necessarily heap let the new value rise to its appropriate place in so that now becomes heap as well to do thiscompare the new value with its parent to check if they are in the correct order if they arethen the procedure haltselse the new value and its parent' value are swapped and step is repeated example solution consider the max heap given in fig and insert in it figure binary heap figure binary heap after insertion of the first step says that insert the element in the heap so that the heap is complete binary tree soinsert the new value as the right child of node in the heap this is illustrated in fig nowas per the second steplet the new value rise to its appropriate place in so that becomes heap as well compare with its parent node value if it is less than its parent' valuethen the new node is in its appropriate place and is heap if the new value is greater than that of its parent' nodethen swap the two values repeat the whole process until becomes heap this is illustrated in fig figure heapify the binary heap