siftup
Siftup, also called percolate up or bubble up, is an operation used in heap-based data structures to restore the heap property after an insertion or a key decrease. In a binary heap stored in an array, a newly inserted element is appended at the end. The siftup procedure compares the element with its parent; if the heap property is violated (for example, in a min-heap if the element is smaller than its parent, or in a max-heap if it is larger), the two are swapped. The element then takes the place of its parent, and the process repeats with the new parent index until the element is at a position where the property holds or the root is reached. The result is that the path from the insertion point to the root is corrected, ensuring the heap remains valid.
Time complexity for siftup in a binary heap is O(log n), since the height of the heap