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 tree of files and folders on a computer.
A stack of plates on a table.
A queue of people waiting for a bus.
What is the purpose of the 'top' pointer in an array-based stack implementation?
To track the index of the next available position for insertion
To store the value of the top element in the stack
To point to the bottom element of the stack
To store the maximum size of the stack
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
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 beginning of the linked list.
At a specific index in the linked list.
At the end of the linked list.
In maze-solving algorithms, how does the use of a stack differ between depth-first search (DFS) and breadth-first search (BFS)?
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.
DFS uses a stack only if the maze is solvable, while BFS always uses a queue.
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.
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)
push (insert at the rear)
inject (insert at the front)
In a stack implemented using a singly linked list, which end of the list typically represents the top of the stack?
Middle
It can be either the head or the tail, depending on the implementation.
Tail
Head
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.
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.
What is the primary difference between 'pop' and 'peek' operations on a 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.
'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.
Which of the following stack operations has a time complexity of O(1) in both array-based and linked list-based implementations?
Push
All of the above
Pop
Peek