Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 Consider the following input. 12 10 1 14 6 5 8 15 3 9 7 4 11 13 2 a) Make a co

ID: 3611866 • Letter: 1

Question

1                                                                                    

Consider the following input.

12

10

1

14

6

5

8

15

3

9

7

4

11

13

2

a)      Make a complete binary tree

b)      Convert this tree into a maxheap

c)      Show deleteMax operation on heapof part(b)

Note:Answer all parts of QuestionNo.1 in pictorial form

2                    

a)     We can use a heap to implement a priority queue.

The Serve( ) function returnsthe highest priority item that will be the maximum heap element.The Enqueue () function inserts an input value into heap.“Enqueue ( )” function first add a new node to thetree. Then it traverses a path from this lead toward the root tofind a proper place for this new element.

Write pseudo code for Serve( ) and Enqueue ( ) function.

b)     Suppose H is a min heap containing n keys (elements). We want towrite a function printSmaller() that printsall the keys in H that are smaller than a given input key x.

12

10

1

14

6

5

8

15

3

9

7

4

11

13

2

Explanation / Answer

1 Consider the following input. 12 10 1 14 6 5 8 15 3 9 7 4 11 13 2 a) Make a co