MCS-031 - Question 1: Ans: (Iii) Heap Sort
MCS-031 - Question 1: Ans: (Iii) Heap Sort
187,62,155,343,184,958,365,427,78,94,121,388
187
187
62
Step 3: (Inserting 155) Here the values in the right side must be
greater than the root, but while inserting
187 155 it violates the heap rule, so the heap
must be adjusted as follows:
155
62 155
62 187
62 187
343
62 62 62
Step 5: (Inserting 184) Step 6: (Inserting 958)
187 187
187
62 184 343
187 187
187 187
427 62
Page 2 of 5
187 427
62 62
427 343
62 62
343
187 427
187 427
62 78
62 155 94
62 155
Page 3 of 5
Adjusting 94 as follows:
343 343
94 427 94 427
343
155 427
155 427
78 187 365 958
62 94 184
62 94 184 121
Now adjusting 121 as follows:
343 343
Page 4 of 5
343
121 427
62 94 155 187
121 427
121 427
Page 5 of 5