| Hide text Hide pseudo-code | |
| 
 The HeapSort algorithm has been executed until line 2. In the figure, you can see the input array (both as an array and a binary tree representations). Continue the execution from line 2.  | 
HeapSort(array heap, int heapsize)
1. BuildHeap(heap, heapsize)
2. while heapsize > 1 do
3.   heap[heapsize-1] = 
        DeleteMax(heap, heapsize) 
4.   heapsize = heapsize - 1
 |