Q.enqueue(5) Q.enqueue(2) Q.dequeue() Q.enqueue(3) Q.dequeue()
for (int k = 1; k ≤ 7; k++) Q.enqueue(k); for (int k = 1; k ≤ 7; k++) Q.enqueue(Q.dequeue());
Final answer:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
public Queue<String> contains(Queue<String> q, String str)
that takes a Queue and an element and returns true if the Queue contains this element or false if not. The elements in the Queue must remain in their original order once this method is complete.