Consider a circular queue implemented using an array. If the front is at index 5 and the rear is at index 2 (with a valid queue configuration), what is the current size of the queue (assuming the array has a capacity greater than the queue size)?
4
7
3
Cannot be determined with the given information
What is the time complexity of enqueue and dequeue operations in a well-implemented queue using a linked list?
O(n log n)
O(1)
O(log n)
O(n)
Consider two queues: Q1 implemented using a singly linked list and Q2 implemented using a circular array. Both queues currently hold n elements. What is the difference in time complexity for dequeuing all elements from Q1 and Q2?
Q1 has O(n^2) complexity, Q2 has O(n) complexity
Q1 has O(n) complexity, Q2 has O(n^2) complexity
Q1 has O(n) complexity, Q2 has O(1) complexity
Both have the same time complexity, O(n)
In what scenario would using a deque NOT provide a significant performance advantage over a regular queue?
When implementing a job scheduling queue with different priority levels
When processing a stream of data in a First-In, First-Out (FIFO) manner
When elements need to be added and removed from both ends frequently
When implementing a Least Recently Used (LRU) cache with a fixed size
You need to implement a queue with the following operations: enqueue, dequeue, and find the minimum element in the queue in O(1) time complexity. Which data structure would be most efficient for this scenario?
Two queues
A queue and a stack
A queue and a min-heap
A single queue
What is a significant disadvantage of implementing a queue using a single linked list compared to a doubly linked list?
Slower enqueue operations as the tail needs to be traversed
More complex implementation logic
Increased memory usage due to the extra 'next' pointer
Inability to perform efficient dequeue operations
In a circular queue implemented with an array of size 5, if front = 2 and rear = 4, what will be the new values of front and rear after two dequeue operations, followed by one enqueue operation?
front = 4, rear = 0
front = 1, rear = 2
front = 0, rear = 1
front = 3, rear = 0
How does the time complexity of adding or removing an element from the front of a deque compare to doing the same at the back?
The time complexity depends on the specific implementation of the deque.
Adding or removing from the front is always faster.
Adding or removing from the back is always faster.
Adding or removing from either end has the same time complexity, which is typically O(1).
In a circular queue implemented using an array of size N, what is the most efficient way to check if the queue is full?
(rear + 1) % N == front
front == 0
rear == N - 1
front == rear
You are building a system to manage a print queue for a network printer. Multiple computers can send print jobs (represented as objects) to the queue. Which feature of a deque would be MOST beneficial for allowing users to prioritize urgent print jobs?
The ability to insert elements at the front (push_front())
The ability to iterate through the deque in reverse order
Constant time complexity for accessing the last element (back())
Random access to elements in the deque