Heap Sort

If you have a heap - represented as array - during the deletion the last element from the array gets to the root as part of process and followed by heapify operation. The empty place from behind of the can be leveraged to place the deleted element which either going to be a last max and min element of the array. Repeating this operation sorts the array in nlogn fashion

The video discusses heap sort in detail - https://youtu.be/HqPJF2L5h9U?t=1751

The max element 50 and 30 is getting placed from the behind.