Vous êtes sur la page 1sur 2

Assignment 3 Algorithm Deadline: 24-May-2019

Problem 1

1. Build Min heap by adding values one by one from the given elements in the
order given below and show updated min heap after every new added
value
37, 13, 21, 4, 23, 56, 28, 13, 18, 10, 8, 6, 29, 49

2. Build Max heap by adding values one by one from the given elements in the
order given below and show updated max heap after every new added
value
37, 13, 21, 4, 23, 56, 28, 13, 18, 10, 8, 6, 29, 49

You can show all the operations in array form or the tree form but you have to
show every step and change occurred for the array values

For Min heap – for example [First value inserted - 56]

56
For first value, no change needed. [Second value inserted - 45]

56 45
45 56
[Third value inserted - 50]

45 56 50
No change needed

In this way, you can also build heap in the form of array
Problem 2

You have given all the values in array, check whether these values are in the
proper Max heap format, if not in the proper order get these values in the proper
Max heap format and then get these values in the sorted order.

You have to show all the operations in the tree format. Show every change you
have to make in the process.

Array values are <13, 45, 65, 72, 21, 4, 34, 56, 71, 28, 9>

Vous aimerez peut-être aussi