Time Left - 15:00 mins

GATE 2020 : Programming & Data Structures Quiz 6

Attempt now to get your rank among 685 students!

Question 1

What will be the postfix equivalent of the following infix expression:

Question 2

What is the max size of the operand stack while evaluating the postfix exp 8 2 4 + - 2 7 1 / + * ?

Question 3

Let S be a stack of size n ≥1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and Pop operations take X seconds each, and Y seconds elapse between the end of one such stack operation and the start of the next operation. For m ≥1, define the stack-life of m as the time elapsed from the end of Push(m) to the start of the pop operation that removes m from S. The average stack-life of an element of this stack is

Question 4

Consider the problem of Tower of Hanoi in which three towers are there Left, Middle and Right. We have n discs available in the leftmost tower and we want to move them into right tower using middle as intermediate. Now consider the following recursive call :
TOH(n,L,M,R) : This recursive call denotes that n discs needs to be moved from left to right tower using middle as intermediate .
Now consider the following recursive program to solve tower of Hanoi problem :

What will be the recursive statements in the above blanks respectively ?

Question 5

Assume the following input sequence for the stack which is empty.
100,200,300,400,500
Among the given permutations which of them can be the output sequence?

Question 6

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?
  • 685 attempts
  • 4 upvotes
  • 10 comments
Mar 26GATE & PSU CS