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)?
3
Cannot be determined with the given information
7
4
What is the time complexity of enqueue and dequeue operations in a well-implemented queue using a linked list?
O(1)
O(n)
O(log n)
O(n log n)
What type of memory allocation does a linked list-based queue primarily rely on?
Stack allocation
Direct memory access
Heap allocation
Static memory allocation
Imagine you need to design a system for handling requests with different priority levels. High-priority requests should be processed before lower-priority ones. Which queue implementation would be best suited for this scenario?
A circular queue
A LIFO queue (stack)
A priority queue
A standard FIFO queue
In a circular queue implemented using an array of size N, how many elements can the queue hold at any given time?
N + 1
It depends on the data type of the elements
N - 1
N
In what scenario would using a deque NOT provide a significant performance advantage over a regular queue?
When implementing a Least Recently Used (LRU) cache with a fixed size
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 job scheduling queue with different priority levels
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 = 0, rear = 1
front = 1, rear = 2
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?
Adding or removing from the front is always faster.
Adding or removing from the back is always faster.
The time complexity depends on the specific implementation of the deque.
Adding or removing from either end has the same time complexity, which is typically O(1).
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) complexity, Q2 has O(1) complexity
Q1 has O(n) complexity, Q2 has O(n^2) complexity
Q1 has O(n^2) complexity, Q2 has O(n) complexity
Both have the same time complexity, O(n)
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?
A queue and a min-heap
Two queues
A single queue
A queue and a stack