Which of these is NOT a typical application of stacks?
Storing data in a priority-based order
Evaluating mathematical expressions (postfix notation)
Undo/Redo functionality in text editors
Managing function calls in a program's execution
What is the space complexity of a stack that stores n integers?
O(n^2)
O(1)
O(log n)
O(n)
How do stacks and heaps differ in terms of element 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
Stack follows LIFO order, while heap maintains a partial ordering
Which data structure would be most suitable for implementing a Last-In-First-Out (LIFO) access pattern?
Heap
Deque
Queue
Stack
What value does the 'peek' operation return if the stack is empty?
0
-1
It depends on the implementation.
null
You are designing a system to validate arithmetic expressions. Which data structure is most suitable for checking if parentheses '(' '[' '{' are balanced in an expression?
Linked List
Binary Tree
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(n log n)
In a backtracking algorithm, what does the act of popping an element from the stack signify?
Exploring a new path
Backtracking to a previous state
Storing a potential candidate
Finding the solution
In the context of the 'Next Greater Element' problem, what does the term 'next greater' refer to?
The element with the next highest value in a sorted order.
The element that is both to the right and has a larger value.
The element that appears most frequently after the current element.
The element that is lexicographically greater.
What happens when you try to 'pop' an element from an empty stack?
A special value (like -1) is returned.
The program crashes.
A random element from the stack is removed.
It depends on the specific implementation of the stack.