What is the primary difference between a queue and a stack?
Queues use LIFO (Last-In-First-Out), while stacks use FIFO (First-In-First-Out).
Queues store numbers, while stacks store characters.
Queues use FIFO (First-In-First-Out), while stacks use LIFO (Last-In-First-Out).
Queues are linear data structures, while stacks are non-linear.
What is the primary disadvantage of using an array to implement a queue?
High memory usage
Inefficient search operations
Fixed size limitation
Complex implementation
If you were to design a system to handle customer service requests arriving through various channels, with each request needing to be addressed in the order it was received, which data structure would be most appropriate?
Queue
Heap
Graph
Binary Search Tree
How does an array-based queue handle the underflow condition?
By raising an exception or returning an error value when attempting to dequeue from an empty queue.
By overwriting the existing elements.
By using a circular array to reuse the empty spaces.
By dynamically resizing the array.
In which of these scenarios is a queue data structure a suitable choice?
Managing function calls in a recursive program.
Storing a list of recently opened files in an operating system.
Handling requests in a multi-threaded environment based on their arrival order.
Implementing an undo/redo functionality in a text editor.
What is the main advantage of using a circular array for implementing a queue compared to a regular array?
Better handling of sorted data
Faster access to individual elements
Reduced memory consumption
Efficient utilization of space after multiple enqueue and dequeue operations
What data structure is used to implement a priority queue?
Array
Linked List
Stack
In a circular queue implemented using an array of size 5, the front is at index 3, and the rear is at index 1. What happens after two dequeue operations?
The front moves to index 1, and the rear moves to index 4.
The front moves to index 0, and the rear moves to index 4.
The queue becomes empty.
The front moves to index 0, and the rear remains at index 1.
What is the primary characteristic that distinguishes a queue from other linear data structures?
It allows for random access of elements.
Elements are added and removed from the same end.
It is a sorted data structure.
Elements are added at one end and removed from the other.
What is the role of the 'front' pointer in a queue data structure?
It keeps track of the total number of elements in the queue.
It points to the element that has been in the queue the longest.
It points to the location where the next element will be added.
It determines if the queue is full or not.