AlgorandSIMULATION v1.0
Sequential Engines(17)
Parallel Engines
Heap Sort
sequentialRAMAn in-place comparison sort that uses a binary heap data structure to find the maximum element, swap it to the end of the array, and restore the heap property.
SIMULATION STEP PROGRESSStep 1 / 1
SPEED (50%)
SIZE (8)
💡 Tip: Enter integers between 1 and 99. Max size is 15.
Code Workspace
1procedure heapSort(A: list)
2 n := length(A)
3 for i := floor(n/2) - 1 down to 0 do
4 heapify(A, n, i)
5 end for
6 for i := n - 1 down to 1 do
7 swap(A[0], A[i])
8 heapify(A, i, 0)
9 end for
10end procedure
11procedure heapify(A, n, i)
12 largest := i
13 left := 2 * i + 1
14 right := 2 * i + 2
15 if left < n and A[left] > A[largest] then largest := left
16 if right < n and A[right] > A[largest] then largest := right
17 if largest != i then
18 swap(A[i], A[largest])
19 heapify(A, n, largest)
20 end if
21end procedure
Currently highlights executing branch
RUNTIME COST METRICS
Comparisons0
Memory Writes0
Memory Reads0
Elements Swapped0
Computational Model:RAM (Single Core)
Theoretical Bound:O(N log N)
Space Complexity:O(1)
Communication Cost:0 (Shared Bus)
THEORETICAL ANALYSIS & RESEARCH
Conceptual Focus: An in-place comparison sort that uses a binary heap data structure to find the maximum element, swap it to the end of the array, and restore the heap property.
Real-world Industrial Applications:
- Implementing priority queues
- Real-time embedded systems with strict memory bounds
- Order statistics (finding the k-th largest element)