JavaScript is required for this website. Please allow JavaScript and refresh the page.
home Home
sort Sorts
LOGARITHMIC
Quick Sort Merge Sort Heap Sort
QUADRATIC
Bubble Sort Selection Sort Insertion Sort Gnome Sort Shaker Sort Odd Even Sort Pancake Sort
WEIRD
Bitonic Sort Radix Sort Shell Sort Comb Sort Bogo Sort Stooge Sort
CUSTOM
Your Sort
SORT VISUALIZER
Heap Sort
Elements: 100
DESCRIPTION

Heap Sort is an in-place iterative sorting algorithm based on auxiliary data structures called heap. It's less efficient than algorithm with the same time complexity and it's not suitable for data structures with few elements.

The heap is a data structure representable as a binary tree, where each node has a value bigger or equal to its children. Consequently, the root will hold the maximum value.

The data structure gets ordered to form the heap initially, and then it gets progressively reordered with an algorithm similar to Selection Sort, starting from the bigger elements.

COMPLEXITY
Average Complexity O(n × log n)
Best Case O(n × log n)
Worst Case O(n × log n)
Space Complexity O(1)