Question: Consider these functions: insert() : insert an element to the back of the queue remove() : remove an element from the front of the queue
Consider these functions: insert() : insert an element to the back of the queue remove() : remove an element from the front of the queue peek() : returns (not remove) the element from the front of the queue What will be the output after performing these sequence of operations
Queue q; // A queue that holds integers int a = 22, b = 44; q.insert(2); q.insert(a); q.insert(a + b); b = q.peekFront(); q.remove(); q.insert(b); q.insert(a - b); q.remove(); while (!q.empty()) { System.out.println(q.remove()); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
