Which of the following is a significant drawback of implementing a stack using a static array?
Complex implementation
Slow push and pop operations
Fixed size limitation
High memory usage
How does a stack implemented using a linked list handle overflow compared to an array-based implementation?
Linked list implementation also suffers from overflow.
Linked list implementation avoids overflow as long as memory is available.
Both implementations handle overflow similarly.
Linked list implementation prevents overflow by overwriting existing elements.
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.
What is the time complexity of pushing an element onto a stack implemented using a static array, assuming there is enough space?
O(n)
O(1)
O(n log n)
O(log n)
In a 'Next Greater Element' problem, if no greater element exists to the right of an element, what is typically assigned as its 'next greater element'?
The element itself
None of the above
0
-1
How does a stack help in implementing the undo functionality in text editors?
By using a linked list of characters.
By storing a stack of states.
By storing a queue of actions.
By hashing the content.
In which scenario would an array-based stack be a more suitable choice than a linked list-based stack?
When the stack size is known in advance and relatively small.
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.
Which data structure, often used with stacks, helps manage function calls and their execution flow?
Queue
Hash Table
Heap
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 that is lexicographically greater.
The element that is both to the right and has a larger value.
The element with the next highest value in a sorted order.
What is the primary advantage of using a linked list to implement a stack over an array?
Dynamic resizing capability
Lower memory usage
Simpler implementation
Faster push and pop operations