Time Left - 15:00 mins

GATE 2019 - P&DS Quiz-4 (Stack ) (App update required to attempt this test)

Attempt now to get your rank among 673 students!

Question 1

Consider the following expression :

A+B*C*D^E/F-G

Convert this expression into postfix expression and then evaluate it using the stack. We have different stacks available of different sizes. What is the optimal size of stack that must be used to evaluate the above postfix expression _______ .

Question 2

Find postfix expression for the following infix expression? Assume as the highest precedence and follow right to left associativity.
Infix: (a+b)(p+q)(r*s*t)

Question 3

Consider the implementation of multiple stacks in single array S of size P from index 0 to P-1. Size of each stack is Q. The following function PUSH(), used to PUSH data x on to a particular stack I where is used as top variable for stack i(i indicates stack number.)
PUSH (S, P, Q, Ti, x)
{
if (_______A_______)
{
printf(“stack overflow”);
exit (1);
}
else
T++;
S[ Ti ] = x;
}
Stack 0 store element from 0 to Q – 1, stack 1 stores from q to 2Q -1, and similarly other stack will store elements. Which of the following is the correct expression to replace A in the function?

Question 4

A stack can be implemented using two queues. Let the queues be q1, q2 and the stack be s.
The operations push and pop are implemented in the following way:
push(s, x):
a. enqueue x to q1
pop(s):
a. P
b. dequeue last item of q1
c. Q
d. return value in step b
The best possible options for P and Q are respectively

Question 5

The postfix expression to be evaluated as 7 is

Question 6

Suppose you have a stack in which the values 1 through 5 must be pushed on the stack in that order, but that an item on the stack can be popped at any time. Give a sequence of push and pop operations such that the values are popped in the following order:
(a) 2, 4, 5, 3, 1
(b) 1, 5, 4, 2, 3
(c) 1, 3, 5, 4, 2
It might not be possible in which case?
  • 673 attempts
  • 2 upvotes
  • 5 comments
Apr 4GATE & PSU CS