The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
96 views
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.
asked in Algorithms by Active (3.7k points) | 96 views
+1
preparing the heap has 2 method

1) Build Heap

2) Insertion Method

Which one do you want?

1 Answer

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
answered by Active (2.9k points)
0
Down voter should also explain what's wrong.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,534 questions
54,122 answers
187,321 comments
71,040 users