What real-world scenario accurately reflects the functioning of a stack?
Books arranged alphabetically on a shelf
Cars parked in a single-lane driveway
People standing in a queue at a ticket counter
Customers waiting on hold for customer service
Which of these situations would make a stack unsuitable for solving the 'Next Greater Element' problem efficiently?
The input array contains negative numbers.
The input array is sorted in ascending order.
The input array is very large (millions of elements).
The input array has duplicate elements.
Which data structure is most closely related to the concept of recursion?
Stack
Linked List
Tree
Queue
Which data structure is most similar to a deque in terms of functionality?
Binary Search Tree
Heap
Which data structure would be most suitable for implementing a Last-In-First-Out (LIFO) access pattern?
Deque
How does a stack help in converting infix expressions to postfix?
By directly translating the expression
By eliminating the need for parentheses
By prioritizing operators based on precedence
By reversing the order of operands
In which scenario would you prefer using a stack over a queue data structure?
Simulating a first-in, first-out (FIFO) system.
Storing a collection of songs to be played in a shuffled order.
Managing a print queue where tasks are processed in the order they arrive.
Implementing an undo/redo functionality in a text editor.
What happens when you try to 'pop' an element from an empty stack?
The program crashes.
A special value (like -1) is returned.
It depends on the specific implementation of the stack.
A random element from the stack is removed.
How do stacks and heaps differ in terms of element ordering?
Stack follows LIFO order, while heap maintains a partial ordering
Stack follows FIFO order, while heap has no specific order
Stack has no specific order, while heap maintains elements in sorted order
Both stack and heap maintain elements in sorted order, but with different sorting algorithms
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 frequent insertions and deletions are required in the middle of the stack.
When dealing with a very large dataset where memory usage is critical.
When the stack size is known in advance and relatively small.