Stack


Q1.

The expression 1 * 2 \wedge 3 * 4 \wedge 5 * 6 will be evaluated as
GateOverflow

Q2.

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

Q3.

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

Q4.

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
GateOverflow

Q5.

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
GateOverflow

Q6.

Choose the correct alternatives (more than one may be correct) and write the corresponding letters only: The following sequence of operations is performed on a stack: PUSH (10), PUSH (20), POP, PUSH (10), PUSH (20), POP, POP, POP, PUSH (20), POP The sequence of values popped out is
GateOverflow

Q7.

Consider the following C program: #include < stdio.h > #define EOF -1 void push (int); /* push the argument on the stack */ int pop (void); /* pop the top of the stack */ void flagError (); int main () { int c, m, n, r; while ((c = getchar ()) != EOF) { if (isdigit (c) ) push (c); else if ((c == '+') || (c == '*')) { m = pop (); n = pop (); r = (c == '+') ? n + m : n*m; push (r); } else if (c != ' ') flagError (); } printf("% c", pop ()); } What is the output of the program for the following input?5 2 * 3 3 2 + * +
GateOverflow

Q8.

Consider the following sequence of operations on an empty stack. push(54); push(52); pop(); push(55); push(62); s=pop(); Consider the following sequence of operations on an empty queue. enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q=dequeue(); The value of s+q is ___________.
GateOverflow

Q9.

Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?
GateOverflow

Q10.

The result evaluating the postfix expression 10 5 + 60 6 / * 8 - is
GateOverflow