Given a Binary Heap and a new element to be added to this Heap. The task is to insert the new element to the Heap maintaining the properties of Heap.
Process of Insertion: Elements can be inserted to the heap following a similar approach as discussed above for deletion. The idea is to:
First increase the heap size by 1, so that it can store the new element.
Insert the new element at the end of the Heap.
This newly inserted element may distort the properties of Heap for its parents. So, in order to keep the properties of Heap, heapify this newly inserted element following a bottom-up approach.
code link:
https://github.com/HarshitDolu/Heap-a...