Heap sort works by first building a max heap from the input array. This means arranging the array so the largest value is at the root. We do this by heapifying from the last parent node up to the root. Then, we swap the root with the last element in the heap and reduce the heap size by one, effectively placing the largest element at the end of the array. After each swap, we heapify the root again to maintain the max heap property for the remaining elements. We repeat this process until the heap size is one, at which point the array is fully sorted in ascending order. The execution table shows each step with the array state and heap visual, helping to understand how the heap changes during sorting.