Stacks and Queues
1. What will be the front and rear of an initially empty queue after the following operations: enqueue(2), enqueue(11), enqueue(3), dequeue(), enqueue(8), dequeue(), enqueue(5), dequeue()?
2. You are given a simple queue with elements 2, 3, 8, 1, 9, 7, where 2 is the front of the queue. The elements are dequeued one-by-one and pushed into a stack until the queue becomes empty. The elements are then popped from the stack one-by-one and enqueued into the original queue. What is the final arrangement of elements in the queue?
3. What is the minimum number of stacks needed to implement a queue?
4. Which principle does a standard queue follow?
5. Which operation inserts an element into a queue?
6. Which operation removes an element from the front of a queue?
7. In an array-based queue, why is a circular queue useful?
8. Suppose a queue contains 10, 20, and 30 from front to rear. If dequeue() is performed once and then enqueue(40) is performed, what is the resulting order from front to rear?
9. In a queue implemented using two stacks, what is the main purpose of transferring elements from the input stack to the output stack?