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

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.

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