You are on page 1of 4

Cs502 2nd Assignment

MC180203227
Question No.1
a) Draw the final Min-Heap structure for the following array; show the final result (tree) only.

1, 5, 7, 25, 13, 19, 12, 30, 27, 26


Solution:
1

5 7

25 13 19 12
5

30 27 26

b) Draw the final Max-Heap structure for the following array; show the final result (tree) only.

30, 27, 19, 25, 26, 5, 12, 1, 13, 7

Solution:
30

27 19
5

25 26 5 12
5

1 13 7

Question No. 02

You are given an array; you have to apply partition algorithm of quick sort on this array.
You are required to show all the steps of partition algorithm.

9 1 7 20 12 18 2 15 4 17

p r
9 1 7 20 12 18 2 15 4 17
q s

Solution:

You might also like