CS210 Tutorial 11
Complete the following exercises pasted below:
Q1. Illustrate the insertion of the following keys in a
priority queue implementing a heap (max heap)
(2, 5, 16, 4, 10, 23, 39, 18, 26, 15).
Q2. Illustrate the removal of the following keys from the above heap
39, 26, 23.
Q3. Illustrate the result of execution of the following integer keys to be inserted in a priority queue (min heap). Each node in the min heap stores an integer.
10, 4, 3, 5, 11, 7, 1, 0, 6, 9, 8
Q4. Draw the resulting heap from Q3 after removeMin() is
called three times.
Q5. What does each removeMin call return within the following sequence of priority queue (min heap) ADT operations. Each node in the binary tree stores the priority key (integer) and the value (character).
insert(5, A),
insert(9, B),
insert(7, F),
insert(1, D),
insert(3, J),
insert(6, L),
removeMin( ),
removeMin( ),
insert(8, G),
removeMin( ),
insert(2, H),
removeMin( ),
removeMin( )
<SOLUTION>
Q1.
Q2. Enter the values in this visualization
After removing 36
After removing 26
After removing 23
Q3 and Q4. Enter the integer values in this visualization
Q5. Enter the integer values in this visualization