Time Left - 10:00 mins

GATE CS 2018 - Data Structures Quiz 3

Attempt now to get your rank among 1227 students!

Question 1

The best data structure to check whether an arithmetic expression has balanced parentheses is a

Question 2

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:

Question 3

An implementation of a queue Q, using two stacks S1 and S2, is given below:
void insert (Q, x) {
push (S1, x);
}
void delete (Q) {
if (stack-empty(S2)) then
if (stack-empty(S1)) then {
print(“Q is empty”);
return;
}
else while (!(stack-empty(S1))){
x=pop(S1);
push(S2,x);
}
x=pop(S2);
}
Let n insert and m(n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?

Question 4

To evaluate an expression without any embedded function calls

Question 5

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
  • 1227 attempts
  • 7 upvotes
  • 43 comments
Jul 9GATE & PSU CS