Heap SortHeap sort processes the elements by creating the min heap or max heap using the elements of the given array. Min heap or max heap represents the ordering of the array in which root element represents the minimum or maximum element of the array. At each step, the root element of the heap gets deleted and stored into the sorted array and the heap will again be heapified. The heap sort basically recursively performs two main operations.
Complexity
AlgorithmHEAP_SORT(ARR, N)
C ProgramOutput: printing sorted elements 1 1 2 2 2 3 4 10 23 100 Java ProgramOutput: printing sorted elements 1 1 2 2 2 3 4 10 23 100 C# programOutput: printing sorted elements 1 1 2 2 2 3 4 10 23 100
Next TopicInsertion Sort
|