What is the primary difference between 'pop' and 'peek' operations on a stack?
'Pop' and 'peek' are interchangeable terms for the same operation.
'Pop' retrieves the top element's value, while 'peek' removes it from the stack.
'Pop' removes the top element, while 'peek' only retrieves its value without removing it.
'Pop' is used for stacks, while 'peek' is used for queues.
In the context of expression parsing, what role does a stack play?
Generating machine code from the expression.
Optimizing the expression for better performance.
Storing the lexical tokens identified in the expression.
Evaluating the parsed expression directly.
Which real-life scenario most accurately reflects the LIFO (Last In First Out) principle of a stack data structure?
A tree of files and folders on a computer.
A list of tasks sorted by priority.
A queue of people waiting for a bus.
A stack of plates on a table.
What is a potential drawback of using a linked list-based stack compared to an array-based stack?
Limited stack size
Inability to handle dynamic resizing
Increased time complexity for push and pop operations
Higher memory usage due to the overhead of storing pointers
What key advantage does a Deque (Double-ended Queue) offer over a Stack?
Deque is more memory-efficient than a Stack.
Deque allows deletions only at one end.
Deque allows insertions only at one end.
Deque allows insertions and deletions at both ends.
How do stacks facilitate backtracking in algorithms?
By storing the optimal solution found so far.
By providing a mechanism for parallel processing.
By optimizing the search space for the algorithm.
By maintaining a record of visited states and enabling the algorithm to revert to previous states.
What is the primary role of a stack in expression evaluation?
Evaluating the precedence of operators.
Performing arithmetic calculations on operands.
Converting infix expressions to postfix.
Storing the variables used in the expression.
Imagine a stack is used to track function calls in a recursive program. What happens to the stack when a function returns?
The entire stack is cleared.
The stack remains unchanged.
The corresponding function call is popped from the stack.
The corresponding function call is pushed onto the stack.
What is the result of evaluating the prefix expression '-+5*234'?
17
-7
7
-17
In a stack implemented using a singly linked list, which end of the list typically represents the top of the stack?
It can be either the head or the tail, depending on the implementation.
Tail
Middle
Head