diff --git a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md index dae4aec60..382b6f8c5 100644 --- a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md +++ b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md @@ -1,3 +1,3 @@ # Heap Sort -Heap Sort is an efficient, comparison-based sorting algorithm. It utilizes a datastructure known as a 'binary heap', and works by dividing its input into a sorted and an unsorted region, and iteratively shrinking the unsorted region by extracting the largest element and moving that to the sorted region. It's an in-place algorithm but not a stable sort. It involves building a Max-Heap, which is a specialized tree-based data structure, and then swapping the root node (maximum element) with the last node, reducing the size of heap by one and heapifying the root node. The maximum element is now at the end of the list and this step is repeated until all nodes are sorted. Heap Sort offers a good worst-case runtime of O(n log n), irrespective of the input data. +Heap Sort is an efficient, comparison-based sorting algorithm. It utilizes a data structure known as a 'binary heap', and works by dividing its input into a sorted and an unsorted region, and iteratively shrinking the unsorted region by extracting the largest element and moving that to the sorted region. It's an in-place algorithm but not a stable sort. It involves building a Max-Heap, which is a specialized tree-based data structure, and then swapping the root node (maximum element) with the last node, reducing the size of heap by one and heapifying the root node. The maximum element is now at the end of the list and this step is repeated until all nodes are sorted. Heap Sort offers a good worst-case runtime of O(n log n), irrespective of the input data.