in Programming in C edited by
1,130 views
0 votes
0 votes

gate heap sort question

please help me out in solving this question. the solution provided there is not upto the mark

in Programming in C edited by
1.1k views

4 Comments

Well Guys, The answer is 7
0
0

@sachidanand_dwivedi can you post solution provided by them

 

1
1
Is the answer 3? Please give the answer...
0
0

2 Answers

0 votes
0 votes

in heap sort loop runs for n times for every node and in each loop it calls heapify function 1 time 

after 1st iteration largest element is at its place

after 2nd iteration 2nd largest element is at its place

after 3rd iteration  3rd largest element is at its place 

and so on 

in the given output we can see that only last 3 elements are in their position that are 20,23and 25

so heapify would have been called 3 time .So the answer is 3

 

 

0 votes
0 votes
in heap sort loop runs for n times for every node and in each loop it calls heapify function 1 time

after 1st iteration largest element is at its place

after 2nd iteration 2nd largest element is at its place

after 3rd iteration  3rd largest element is at its place

and so on

in the given output we can see that only last 3 elements are in their position that are 20,23and 25

so heapify would have been called 3 time .So the answer is 3