What real-world scenario accurately reflects the functioning of a stack?
People standing in a queue at a ticket counter
Books arranged alphabetically on a shelf
Customers waiting on hold for customer service
Cars parked in a single-lane driveway
What happens when you try to 'pop' an element from an empty stack?
A special value (like -1) is returned.
It depends on the specific implementation of the stack.
The program crashes.
A random element from the stack is removed.
In which scenario would an array-based stack be a more suitable choice than a linked list-based stack?
When the maximum size of the stack is unknown.
When dealing with a very large dataset where memory usage is critical.
When frequent insertions and deletions are required in the middle of the stack.
When the stack size is known in advance and relatively small.
In the context of the 'Next Greater Element' problem, what does the term 'next greater' refer to?
The element that appears most frequently after the current element.
The element with the next highest value in a sorted order.
The element that is lexicographically greater.
The element that is both to the right and has a larger value.
If you implement a stack using an array, what problem might you encounter if you keep pushing elements onto the stack without any limit?
Segmentation Fault
Stack Overflow
Memory Leak
None of the above
Which data structure is most similar to a deque in terms of functionality?
Queue
Binary Search Tree
Heap
Stack
How does a stack implemented using a linked list handle overflow compared to an array-based implementation?
Linked list implementation prevents overflow by overwriting existing elements.
Linked list implementation also suffers from overflow.
Linked list implementation avoids overflow as long as memory is available.
Both implementations handle overflow similarly.
What is the time complexity of pushing an element onto a stack implemented using a static array, assuming there is enough space?
O(1)
O(n log n)
O(log n)
O(n)
Which data structure would be most suitable for implementing a Last-In-First-Out (LIFO) access pattern?
Deque
What is the space complexity of a stack that stores n integers?
O(n^2)