← Back to Algorithms

Heap Sort

A comparison-based sorting algorithm that uses a binary heap data structure. It divides the input into a sorted and an unsorted region, and iteratively shrinks the unsorted region by extracting the largest element.

Current Operation

Click 'Sort' to start visualization

Step: 0/0

Time Complexity: O(n log n)
Space Complexity: O(1)

How it Works

Step-by-Step Process:

1. Build max heap from array

2. Extract maximum element and place at end

3. Heapify reduced heap

4. Repeat until array is sorted