GATE 2016 (Session 1) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2016 (Session 1)

65 questions

MCQ 39 · NAT 261-mark 30 · 2-mark 35

Questions 51–55 of 65

Q51Queue2 marksNAT
Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.
while Q is not Empty do
    if S is Empty OR Top(S) ≤ Head(Q) then
        x := Dequeue(Q);
        Push(S,x);
    else
        x := Pop(S);
        Enqueue(Q,x);
    end
end

The maximum possible number of iterations of the while loop in the algorithm is_________.

Q52Context Free Grammar2 marksMCQ−0.67 if wrong
Consider the following context-free grammars:

G1: S→\rightarrowaS|B,
B→\rightarrowb|bB
G2: S→\rightarrowaA|bB,
A→\rightarrowaA|B|ε\varepsilon,
B→\rightarrowbB|ε\varepsilon

Which one of the following pair of languages is generated by G1 and G2, respectively?

Q53Push-down Automata2 marksMCQ−0.67 if wrong
Consider the transition diagram of a PDA given below with input alphabet Σ\Sigma={a,b} and stack alphabet Γ\Gamma={X,Z}. Z is the initial stack symbol. Let L denote the language accepted by the PDA.
a,X/XX a,Z/XZ b,X/ε b,X/ε ε,Z/Z
Which one of the following is TRUE?

Q54Recursive Language2 marksMCQ−0.67 if wrong
Let X be a recursive language and Y be a recursively enumerable but not recursive language. Let W and Z be two languages such that Yˉ\bar{Y} reduces to W, and Z reduces to Xˉ\bar{X} (reduction means the standard many-one-reduction). Which one of the following statements is TRUE?

Q55Arithmetic Operation2 marksNAT
The attributes of three arithmetic operators in some programming language are given below.
Operator Precedence Associativity Arity +HighLeftBinary MediumRightBinary *LowLeftBinary
The value of the expression 2-5+1-7*3 in this language is_______ .