⇰ HEAP SORT :-
Heap sort is also a type of sorting technique, which can apply in binary tree sorting. Heap sort technique is comparison based sorting technique based on Heap data structure. This technique is similar to the selection sort . But first of all we need to know about Heap data structure. A Binary Heap is a Complete Binary Tree where items are stored in a special order such that root node is compared with its children and arranged accordingly. The heap is of two types:- Min heap ( value of root node is less than or equal to child) , Max heap ( value of root node is greater or equal to child). The heap can be represented by binary tree or array.
⇰ ALGORITHM HEAP SORT :-
Step1 :- Write root in the list.
Step2 :- Write last element at the root.
Step3 :- Heapify the tree.
Step4 :- Repeat all three steps.
⇰ IMPLEMENTATION OF HEAP SORT :-
Let us take a heap:-
We take element and put into list
Share, Follow and please comment if you find anything incorrect or to share more information about the topic discussed above
Comments
Post a Comment
Please comment.