Heap sort is one of the sorting algorithms used to arrange a list of elements in order. Heap sort algorithm uses one of the tree concepts called Heap Tree. In this sorting algorithm, we use Max Heap to arrange list of elements in Descending order and Min Heap to arrange list elements in Ascending order.
Step by Step Process
The Heap sort algorithm to arrange a list of elements in ascending order is performed using following steps...
- Step 1 - Construct a Binary Tree with given list of Elements.
- Step 2 - Transform the Binary Tree into Min Heap.
- Step 3 - Delete the root element from Min Heap using Heapify method.
- Step 4 - Put the deleted element into the Sorted list.
- Step 5 - Repeat the same until Min Heap becomes empty.
- Step 6 - Display the sorted list.
Example
No comments:
Post a Comment