Which data structure is most closely related to the concept of recursion?
Queue
Tree
Linked List
Stack
In the context of the 'Next Greater Element' problem, what does the term 'next greater' refer to?
The element that is lexicographically greater.
The element that appears most frequently after the current element.
The element that is both to the right and has a larger value.
The element with the next highest value in a sorted order.
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)
O(1)
O(log n)
O(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'?
-1
None of the above
The element itself
0
In the context of memory allocation within a program, what type of stack is used?
Call Stack
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 implementing the undo functionality in text editors?
By using a linked list of characters.
By hashing the content.
By storing a queue of actions.
By storing a stack of states.
In depth-first search (DFS) algorithms, what role does the stack play?
Storing visited nodes
Calculating shortest paths
Maintaining the order of node exploration
Storing edge weights
What value does the 'peek' operation return if the stack is empty?
It depends on the implementation.
null
Which of these is NOT a typical application of stacks?
Evaluating mathematical expressions (postfix notation)
Undo/Redo functionality in text editors
Storing data in a priority-based order
Managing function calls in a program's execution