Illustrate the working of heapsort on the following arrays:
i. 2, 3, 4, 5, 6, 7
ii. 7, 6, 5, 4, 3, 2
Heapsort builds tree where items are stored in a special order such that the value in a parent node is greater (smaller) than the values in its two children nodes.
ii.
7, 6, 5, 4, 3, 2
i.
2(0), 3(1), 4(2), 5(3), 6(4), 7(5)
Comments
Leave a comment