Consider the scenario of undoing actions in a text editor. Which data structure would be most suitable for implementing an 'undo' feature?
Queue
Stack
Linked List
Binary Tree
What is the primary role of a stack in expression evaluation?
Storing the variables used in the expression.
Evaluating the precedence of operators.
Converting infix expressions to postfix.
Performing arithmetic calculations on operands.
Which of the following stack operations has a time complexity of O(1) in both array-based and linked list-based implementations?
Pop
Push
Peek
All of the above
In a stack implemented using a singly linked list, which end of the list typically represents the top of the stack?
Tail
Middle
Head
It can be either the head or the tail, depending on the implementation.
During the infix to postfix conversion of the expression 'A+B*C-D/E', which operator would be pushed onto the stack first?
/
What is the primary difference between 'pop' and 'peek' operations on a stack?
'Pop' is used for stacks, while 'peek' is used for queues.
'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' and 'peek' are interchangeable terms for the same operation.
What is a potential drawback of using a linked list-based stack compared to an array-based stack?
Inability to handle dynamic resizing
Limited stack size
Increased time complexity for push and pop operations
Higher memory usage due to the overhead of storing pointers
Which real-life scenario most accurately reflects the LIFO (Last In First Out) principle of a stack data structure?
A stack of plates on a table.
A list of tasks sorted by priority.
A tree of files and folders on a computer.
A queue of people waiting for a bus.
You need to implement a stack that can store a large number of items and the maximum number of items is unknown. Which implementation would be more suitable?
Stack using a fixed-size array
Stack using a dynamic array
Stack using a singly linked list
Stack using a doubly linked list
If you represent an arithmetic expression in postfix notation using a stack, what operation would you perform when encountering an operand (a number)?
Ignore the operand.
Pop the top two elements from the stack, perform the operation, and push the result back onto the stack.
Check if the stack is empty.
Push the operand onto the stack.