What is the primary disadvantage of implementing a stack using a fixed-size array?
Higher memory usage compared to dynamic arrays
Inability to handle stacks larger than the predetermined size
Increased time complexity for push and pop operations
Complex implementation requiring advanced pointer manipulation
Which of the following stack operations has a time complexity of O(1) in both array-based and linked list-based implementations?
Peek
All of the above
Pop
Push
How do stacks facilitate backtracking in algorithms?
By maintaining a record of visited states and enabling the algorithm to revert to previous states.
By storing the optimal solution found so far.
By providing a mechanism for parallel processing.
By optimizing the search space for the algorithm.
What key advantage does a Deque (Double-ended Queue) offer over a Stack?
Deque is more memory-efficient than a Stack.
Deque allows insertions and deletions at both ends.
Deque allows insertions only at one end.
Deque allows deletions only at one end.
Which of the following operations is NOT typically associated with a Deque?
inject (insert at the front)
peek (view the element at the front without removing)
pop (remove from the rear)
push (insert at the rear)
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' and 'peek' are interchangeable terms for the same operation.
'Pop' removes the top element, while 'peek' only retrieves its value without removing it.
How are stacks utilized in syntax parsing within compilers?
For storing the symbol table of variables.
To check for matching parentheses, braces, and brackets.
To generate intermediate code during compilation.
For performing code optimization.
What is the primary role of a stack in expression evaluation?
Storing the variables used in the expression.
Performing arithmetic calculations on operands.
Evaluating the precedence of operators.
Converting infix expressions to postfix.
In a stack implemented using a linked list, where does the 'push' operation add the new element?
At a specific index in the linked list.
At the beginning of the linked list.
It depends on the data being inserted.
At the end of the linked list.
Consider the scenario of undoing actions in a text editor. Which data structure would be most suitable for implementing an 'undo' feature?
Binary Tree
Stack
Queue
Linked List