Heap Sort uses a max-heap data structure to find the largest element efficiently, then repeatedly extracts it to build a sorted array.
Transform the array into a max-heap where every parent node is greater than its children.