What is the result of evaluating the prefix expression '-+5*234'?
-7
7
-17
17
What key advantage does a Deque (Double-ended Queue) offer over a Stack?
Deque allows insertions only at one end.
Deque allows insertions and deletions at both ends.
Deque allows deletions only at one end.
Deque is more memory-efficient than a Stack.
You need to implement a stack that can store a large number of items and the maximum number of items is unknown. Which implementation would be more suitable?
Stack using a dynamic array
Stack using a singly linked list
Stack using a fixed-size array
Stack using a doubly linked list
What is the time complexity of the 'peek' operation in a well-implemented stack?
O(n)
O(n log n)
O(1)
O(log n)
What is the primary difference between 'pop' and 'peek' operations on a stack?
'Pop' removes the top element, while 'peek' only retrieves its value without removing it.
'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' is used for stacks, while 'peek' is used for queues.
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
Complex implementation requiring advanced pointer manipulation
Increased time complexity for push and pop operations
How are stacks utilized in syntax parsing within compilers?
For performing code optimization.
To check for matching parentheses, braces, and brackets.
To generate intermediate code during compilation.
For storing the symbol table of variables.
In postfix evaluation, what action is taken when an operand is encountered?
It is pushed onto the stack.
It triggers the evaluation of operators on the stack.
It is ignored.
It is immediately evaluated.
How do stacks facilitate backtracking in algorithms?
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.
By optimizing the search space for the algorithm.
What is the primary role of a stack in expression evaluation?
Storing the variables used in the expression.
Performing arithmetic calculations on operands.
Converting infix expressions to postfix.
Evaluating the precedence of operators.