Consider the scenario of undoing actions in a text editor. Which data structure would be most suitable for implementing an 'undo' feature?
Stack
Queue
Binary Tree
Linked List
What is the primary disadvantage of implementing a stack using a fixed-size array?
Inability to handle stacks larger than the predetermined size
Complex implementation requiring advanced pointer manipulation
Increased time complexity for push and pop operations
Higher memory usage compared to dynamic arrays
Which real-life scenario most accurately reflects the LIFO (Last In First Out) principle of a stack data structure?
A list of tasks sorted by priority.
A stack of plates on a table.
A queue of people waiting for a bus.
A tree of files and folders on a computer.
What is a potential drawback of using a linked list-based stack compared to an array-based stack?
Higher memory usage due to the overhead of storing pointers
Limited stack size
Inability to handle dynamic resizing
How are stacks utilized in syntax parsing within compilers?
To generate intermediate code during compilation.
For performing code optimization.
To check for matching parentheses, braces, and brackets.
For storing the symbol table of variables.
During the infix to postfix conversion of the expression 'A+B*C-D/E', which operator would be pushed onto the stack first?
/
Which of the following stack operations has a time complexity of O(1) in both array-based and linked list-based implementations?
Pop
Push
All of the above
Peek
In a stack implemented using a linked list, where does the 'push' operation add the new element?
It depends on the data being inserted.
At the end of the linked list.
At the beginning of the linked list.
At a specific index in the linked list.
What is the time complexity of the 'peek' operation in a well-implemented stack?
O(1)
O(n)
O(n log n)
O(log n)
What is the primary role of a stack in expression evaluation?
Converting infix expressions to postfix.
Performing arithmetic calculations on operands.
Evaluating the precedence of operators.
Storing the variables used in the expression.