Heap Sort

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) |