In which of these scenarios is a queue data structure a suitable choice?
Managing function calls in a recursive program.
Handling requests in a multi-threaded environment based on their arrival order.
Storing a list of recently opened files in an operating system.
Implementing an undo/redo functionality in a text editor.
In a queue data structure, what does the 'enqueue' operation perform?
Removes and returns the element at the front of the queue.
Adds an element to the rear of the queue.
Checks if the queue is empty.
Adds an element to the front of the queue.
Which real-world scenario best exemplifies the use of a queue data structure?
Managing a list of students sorted alphabetically
Finding the shortest route between two points
Storing a family tree with ancestors and descendants
Tracking the order of tasks assigned to a CPU
What is the primary disadvantage of using an array to implement a queue?
Complex implementation
Fixed size limitation
Inefficient search operations
High memory usage
How does an array-based queue handle the underflow condition?
By dynamically resizing the array.
By overwriting the existing elements.
By raising an exception or returning an error value when attempting to dequeue from an empty queue.
By using a circular array to reuse the empty spaces.
What is the primary characteristic that distinguishes a queue from other linear data structures?
Elements are added and removed from the same end.
It allows for random access of elements.
Elements are added at one end and removed from the other.
It is a sorted data structure.
Consider an array-based queue with 'front' at index 3 and 'rear' at index 7. After two dequeue operations, what will be the new value of 'front'?
2
1
6
5
What data structure is used to implement a priority queue?
Array
Heap
Linked List
Stack
If a queue is implemented using a fixed-size array, what condition leads to a 'queue overflow' situation?
Trying to access an element beyond the queue's capacity.
Trying to sort the elements in the queue.
Trying to add an element to a full queue.
Trying to remove an element from an empty queue.
What happens to the elements in an array-based queue after a dequeue operation?
The array is resized to accommodate the removal of the element.
The 'front' pointer is adjusted to point to the next element in the queue, effectively removing the first element logically.
The remaining elements are shifted one position towards the front of the array.
The dequeued element is marked as deleted but remains in the array.