In a stack implemented using a linked list, where does the 'push' operation add the new element?
At the beginning of the linked list.
At the end of the linked list.
At a specific index in the linked list.
It depends on the data being inserted.
Which of the following operations is NOT typically associated with a Deque?
peek (view the element at the front without removing)
pop (remove from the rear)
inject (insert at the front)
push (insert at the rear)
What is the primary role of a stack in expression evaluation?
Converting infix expressions to postfix.
Storing the variables used in the expression.
Evaluating the precedence of operators.
Performing arithmetic calculations on operands.
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.
Push the operand onto the stack.
Check if the stack is empty.
What key advantage does a Deque (Double-ended Queue) offer over a Stack?
Deque allows insertions and deletions at both ends.
Deque allows deletions only at one end.
Deque allows insertions only at one end.
Deque is more memory-efficient than a Stack.
What is a potential drawback of using a linked list-based stack compared to an array-based stack?
Inability to handle dynamic resizing
Higher memory usage due to the overhead of storing pointers
Increased time complexity for push and pop operations
Limited stack size
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 corresponding function call is pushed onto the stack.
The stack remains unchanged.
The corresponding function call is popped from the stack.
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.
In maze-solving algorithms, how does the use of a stack differ between depth-first search (DFS) and breadth-first search (BFS)?
BFS uses a stack to prioritize unexplored paths, while DFS uses a queue to systematically explore all directions.
Both DFS and BFS use stacks identically; the difference lies in how they mark visited nodes.
DFS uses a stack only if the maze is solvable, while BFS always uses a queue.
DFS uses a stack to explore as deeply as possible before backtracking, while BFS uses a queue to explore all neighbors at a given level.
In a linked list-based stack implementation, what does the 'isEmpty()' operation typically check?
If the stack has reached its maximum capacity
If the stack contains any elements with a value of zero
If the tail pointer is pointing to NULL
If the head pointer is pointing to NULL