Vous êtes sur la page 1sur 17

Question:01

Take two different binary tree with atleast 12 vertices and


converet them into heap using step by step processing of
build heap algorithm…

23

25 19

27 24 14 18

28 26 12 17 20 13
Step:01
Using heapify method: so 20 is greater than 14 so we swap the
value 14 and 20.
Step:02
Using heapify method:
In step 02 the value of parent is 24. Greater than its childeren so the heapify
property is fullfil. So thrie is is no need of swapping.

23

25 19

27 24 20 18

28 26 12 17 14 13

Step:03
Using heapify method:
In step 03,thevalueof 28 is greater than 27.so we swap the 27 and 28.
23

25 19

27 24 14 18

28 26 12 17 20 13
Step no:04
IN this step the value of parentis 19so we swapit with 20.
23

25 19
23

28 24 20 18
25 20

27 26 12 17 14 13
28 24 19 18

27 26 12 17 14 13
Step:05
23
23

25 20
25 20

28 24 19 18
28 24 19 18

27 26 12 17 14 13
27 26 12 17 14 13
Step:05

23

28 20

25 24 19 18

27 26 12 17 14 13
Step:06
23

28 20

25 24 19 18

27 26 12 17 14 20
Step:05

28

23 20

25 24 19 18

27 26 12 17 14 13
Step:07

28

23 20

25 24 19 18

27 26 12 17 14 13
Step:07

28

25 20

23 24 19 18

27 26 12 17 14 13
Step:07

28

25 20

23 24 19 18

27 26 12 17 14 13
Step:07

28

25 20

27 24 19 18

23 26 12 17 14 13
Step:07

28

25 20

27 24 19 18

23 26 12 17 14 13
Step:07

28

27 20

25 24 19 18

23 26 12 17 14 13
Step:07

28

27 20

25 24 19 18

23 26 12 17 14 13
Step:07

28

27 20

26 24 19 18

23 25 12 17 14 13

Vous aimerez peut-être aussi