1,058 views
1 votes
1 votes
Sort The Following Sequence of input using Heap sort.

{ 10 , 2 , 1 , 5, 3 ,8 ,11,24 ,7 }

Please show the output at every pass because i am getting confused.

1 Answer

0 votes
0 votes
I am assuming that you want to sort in Ascending Order, so i am going to use Max Heap.

Pick to Root and Replace it with Last Node

Heapify with size less than 1 as the last element is in correct place.

24,15,11,7,3,1,8,2,5

15,7,11,5,3,1,8,2,24

11,7,8,5,3,1,2,15,24

8,7,2,5,3,1,11,15,24

7,5,2,1,3,8,11,15,24

5,3,2,1,7,8,11,15,24

3,1,2,5,7,8,11,15,24

2,1,3,5,7,8,11,15,24

1,2,3,5,7,8,11,15,24

Related questions

1 votes
1 votes
1 answer
1
reena_kandari asked Jul 30, 2016
996 views
The number of elements that can be sorted in time using heap sort ?
1 votes
1 votes
1 answer
2
Himanshu1 asked Jan 20, 2016
1,294 views
What is the Best Case run time of Heap Sort ?A. $O(1)$B. $O(n)$C. $O(n \log n)$D. $O(\log n)$
0 votes
0 votes
0 answers
4