Assume you have a queue q that includes the following elemen
Assume you have a queue q that includes the following elements: The left element 2.5 is the first element of the queue (head) and the right element -2.5 is the element that was added last. The same format is used when the output is printed What is the output printed by the following method call? mystery 2(q, 3); private static void mystery2 (Queue Float q, int n) q. size(); for (int i 0; i size; i++) Float next q.dequeue(); if (i n) q enqueue (next); stdout. print ln(q);
Solution
1) given q=2.5,-5.0,-7.5,0.0,5.0,-2.5
In for loop
next=q.deueue();
next=2.5
then in if
q.enqueue(next);
2.5 will be added in q
similarly for loop and if loop will continue till condition true
At last in q only three values will be there
q=2.5,-5.0,-7.5
Output : 2.5,-5.0,-7.5
2) Version A 3 code
Version B 1 code
Version C 2 code
3) Code A : Heap Sort
Code B : Quick Sort
4) Trace A : Bubble Sort
Trace B : Selection Sort
