What is the primary difference between a queue and a stack?
Queues are linear data structures, while stacks are non-linear.
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).
What is the primary disadvantage of using an array to implement a queue?
Complex implementation
Inefficient search operations
High memory usage
Fixed size limitation
What value does the 'isEmpty' operation on a queue return if the queue contains no elements?
True
-1
The first element in the queue
0
What is the time complexity of enqueue and dequeue operations in a well-implemented array-based queue?
O(n), where n is the number of elements in the queue.
O(log n)
It depends on the size of the array.
O(1)
Which of the following real-world scenarios can be effectively modeled using a queue?
Implementing an undo/redo functionality in a text editor.
Storing the browsing history in a web browser.
Handling customer service requests in a first-come, first-served manner.
Managing a priority-based task list.
When would it be more advantageous to use a linked list implementation of a queue over an array-based implementation?
When memory usage needs to be tightly controlled.
When dynamic resizing and the potential for overflow are concerns.
When the maximum number of elements in the queue is known in advance.
When dealing with a small, fixed number of elements.
What is the worst-case time complexity of searching for an element in a queue implemented using a linked list?
O(n)
O(n log n)
If a queue is implemented using a fixed-size array, what condition leads to a 'queue overflow' situation?
Trying to add an element to a full queue.
Trying to access an element beyond the queue's capacity.
Trying to sort the elements in the queue.
Trying to remove an element from an empty queue.
How does an array-based queue handle the underflow condition?
By using a circular array to reuse the empty spaces.
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.
What is the primary characteristic that distinguishes a queue from other linear data structures?
Elements are added at one end and removed from the other.
It allows for random access of elements.
Elements are added and removed from the same end.
It is a sorted data structure.