Stack


Q11.

Choose the equivalent prefix form of the following expression(a+(b-c))^{\star}((d-e) /(f+g-h))
GateOverflow

Q12.

A function f defined on stacks of integers satisfies the following properties. f(\emptyset) = 0 and f (push (S, i)) = max (f(S), 0) + i for all stacks S and integers i. If a stack S contains the integers 2, -3, 2, -1, 2 in order from bottom to top, what is f(S)?
GateOverflow

Q13.

If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values
GateOverflow

Q14.

A stack is implemented with an array of { }^{\prime} A[0 \ldots N-1]^{\prime} and a variable \text { 'pos'. } The push and pop operations are defined by the following code. push (x) A[pos] <- x pos <- pos -1 end push pop() pos <- pos+1 return A[pos] end popWhich of the following will initialize an empty stack with capacity N for the above implementation?
GateOverflow

Q15.

Which of the following is essential for converting an infix expression to the postfix form efficiently?
GateOverflow

Q16.

A single array A[1...MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top 2 (top1 \lt top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for "stack full" is
GateOverflow

Q17.

The postfix expression for the infix expression A+B*(C+D)/F+D*E is:
GateOverflow

Q18.

The following postfix expression with single digit operands is evaluated using a stack: 8 2 3 ^ / 2 3 * + 5 1 * - Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
GateOverflow

Q19.

Convert the pre-fix expression to in-fix -^{*}+A B C^{*}-D E+F G
GateOverflow

Q20.

Assume that the operators +, -, x , are left associative and ^ is right associative. the order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b x c-d^e^f is
GateOverflow