What key advantage does a Deque (Double-ended Queue) offer over a Stack?
Deque allows deletions only at one end.
Deque allows insertions and deletions at both ends.
Deque is more memory-efficient than a Stack.
Deque allows insertions only at one end.
Which of the following operations is NOT typically associated with a Deque?
inject (insert at the front)
push (insert at the rear)
peek (view the element at the front without removing)
pop (remove from the rear)
Which real-life scenario most accurately reflects the LIFO (Last In First Out) principle of a stack data structure?
A queue of people waiting for a bus.
A stack of plates on a table.
A tree of files and folders on a computer.
A list of tasks sorted by priority.
In maze-solving algorithms, how does the use of a stack differ between depth-first search (DFS) and breadth-first search (BFS)?
Both DFS and BFS use stacks identically; the difference lies in how they mark visited nodes.
BFS uses a stack to prioritize unexplored paths, while DFS uses a queue to systematically explore all directions.
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.
What is the primary role of a stack in expression evaluation?
Evaluating the precedence of operators.
Storing the variables used in the expression.
Converting infix expressions to postfix.
Performing arithmetic calculations on operands.
What is a potential drawback of using a linked list-based stack compared to an array-based stack?
Limited stack size
Increased time complexity for push and pop operations
Inability to handle dynamic resizing
Higher memory usage due to the overhead of storing pointers
What is the result of evaluating the prefix expression '-+5*234'?
-17
7
-7
17
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.
Push the operand onto the stack.
Pop the top two elements from the stack, perform the operation, and push the result back onto the stack.
Ignore the operand.
How do stacks facilitate backtracking in algorithms?
By optimizing the search space for the algorithm.
By maintaining a record of visited states and enabling the algorithm to revert to previous states.
By providing a mechanism for parallel processing.
By storing the optimal solution found so far.
What is the purpose of the 'top' pointer in an array-based stack implementation?
To store the maximum size of the stack
To point to the bottom element of the stack
To track the index of the next available position for insertion
To store the value of the top element in the stack