Consider the scenario of undoing actions in a text editor. Which data structure would be most suitable for implementing an 'undo' feature?
Stack
Linked List
Binary Tree
Queue
In a stack implemented using a singly linked list, which end of the list typically represents the top of the stack?
Tail
Head
Middle
It can be either the head or the tail, depending on the implementation.
What is the time complexity of the 'peek' operation in a well-implemented stack?
O(log n)
O(n log n)
O(n)
O(1)
Which of the following operations is NOT typically associated with a Deque?
peek (view the element at the front without removing)
push (insert at the rear)
inject (insert at the front)
pop (remove from the rear)
What is the primary role of a stack in expression evaluation?
Evaluating the precedence of operators.
Performing arithmetic calculations on operands.
Storing the variables used in the expression.
Converting infix expressions to postfix.
If you represent an arithmetic expression in postfix notation using a stack, what operation would you perform when encountering an operand (a number)?
Check if the stack is empty.
Pop the top two elements from the stack, perform the operation, and push the result back onto the stack.
Ignore the operand.
Push the operand onto the stack.
Which of the following stack operations has a time complexity of O(1) in both array-based and linked list-based implementations?
Push
All of the above
Peek
Pop
In postfix evaluation, what action is taken when an operand is encountered?
It is immediately evaluated.
It triggers the evaluation of operators on the stack.
It is ignored.
It is pushed onto the stack.
In the context of expression parsing, what role does a stack play?
Evaluating the parsed expression directly.
Optimizing the expression for better performance.
Storing the lexical tokens identified in the expression.
Generating machine code from the expression.
What is the result of evaluating the prefix expression '-+5*234'?
-17
-7
7
17