How does a stack help in implementing the undo functionality in text editors?
By storing a stack of states.
By storing a queue of actions.
By using a linked list of characters.
By hashing the content.
What happens when you try to 'pop' an element from an empty stack?
It depends on the specific implementation of the stack.
The program crashes.
A special value (like -1) is returned.
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 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
Stack follows FIFO order, while heap has no specific order
In which scenario would you prefer using a stack over a queue data structure?
Implementing an undo/redo functionality in a text editor.
Managing a print queue where tasks are processed in the order they arrive.
Storing a collection of songs to be played in a shuffled order.
Simulating a first-in, first-out (FIFO) system.
In a stack, how is the element that was added before the last added element accessed?
By popping the top element first.
By searching the entire stack sequentially.
It's not possible to access elements directly in a stack.
Directly using its index.
In depth-first search (DFS) algorithms, what role does the stack play?
Storing visited nodes
Maintaining the order of node exploration
Calculating shortest paths
Storing edge weights
If you implement a stack using a dynamically allocated array, what is the time complexity of pushing an element in the worst-case scenario if you need to resize the array?
O(1)
O(n)
O(n log n)
O(log n)
What is the time complexity of pushing an element onto a stack implemented using a linked list, assuming the push operation is implemented efficiently?
Which data structure would be most suitable for implementing a Last-In-First-Out (LIFO) access pattern?
Deque
Stack
Queue
Heap
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
Memory Leak
Stack Overflow
None of the above