GATE 2016 (Session 1)
65 questions
MCQ 39 · NAT 261-mark 30 · 2-mark 35
Questions 26–30 of 65
Which of the following languages is generated by the given grammar?
Answer: (D)
At every step, the rule puts down one a or one b. It can do this in any order and as many times as needed. So it generates every string over {a, b}, and this also covers .
Answer: {a,b}*
Answer: {a,b}*
Which of the following decision problems are undecidable?
I. Given NFAs N1 and N2, is L(N1)L(N2) = ?
II. Given a CFG G = (N,,P,S) and a string , does L(G)?
III. Given CFGs G1 and G2, is L(G1) = L(G2)?
IV. Given a TM M, is L(M) = ?
I. Given NFAs N1 and N2, is L(N1)L(N2) = ?
II. Given a CFG G = (N,,P,S) and a string , does L(G)?
III. Given CFGs G1 and G2, is L(G1) = L(G2)?
IV. Given a TM M, is L(M) = ?
Answer: (C)
Check each statement:
- I: is the intersection of two NFAs empty? Build the product automaton and test whether a final state is reachable decidable.
- II: does a CFG generate a string x? Use the CYK algorithm decidable.
- III: are two CFGs equal? undecidable. If it were decidable, we could decide whether by comparing G with a grammar for . That universality problem for CFGs is undecidable.
- IV: is a TM's language empty? By Rice's theorem (a non-trivial property of L(M)) undecidable.
So III and IV are undecidable.
Answer: (C)
- I: is the intersection of two NFAs empty? Build the product automaton and test whether a final state is reachable decidable.
- II: does a CFG generate a string x? Use the CYK algorithm decidable.
- III: are two CFGs equal? undecidable. If it were decidable, we could decide whether by comparing G with a grammar for . That universality problem for CFGs is undecidable.
- IV: is a TM's language empty? By Rice's theorem (a non-trivial property of L(M)) undecidable.
So III and IV are undecidable.
Answer: (C)
Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?
Answer: (B)
The string must have "00" somewhere and "11" somewhere, in either order. These two cannot overlap, so either "00" comes first or "11" does:
, which is option (B).
- (A) forces 00 and 11 to be adjacent (0011 or 1100). It misses 001011, which has both.
- (C) needs only one of them (it accepts 00, which has no 11).
- (D) forces them to sit at the very start and the very end. It misses 10011.
Answer: (B)
, which is option (B).
- (A) forces 00 and 11 to be adjacent (0011 or 1100). It misses 001011, which has both.
- (C) needs only one of them (it accepts 00, which has no 11).
- (D) forces them to sit at the very start and the very end. It misses 10011.
Answer: (B)
Consider the following code segment.
x =u-t;
y =x*v;
x =y+w;
y =t-z;
y =x*y;
The minimum number of total variables required to convert the above code segment to static single assignment form is__________ .
x =u-t;
y =x*v;
x =y+w;
y =t-z;
y =x*y;
The minimum number of total variables required to convert the above code segment to static single assignment form is__________ .
Answer: 10
In SSA form, each assignment creates a new variable:
The new variables are (5 in all). Add the input variables u, t, v, w, z (5 in all).
Total = 10
Answer: 10
The new variables are (5 in all). Add the input variables u, t, v, w, z (5 in all).
Total = 10
Answer: 10
Consider an arbitrary set of CPU-bound processes with unequal CPU burst lengths submitted at the same time to a computer system.Which one of the following process scheduling algorithms would minimize the average waiting time in the ready queue?
Answer: (A)
All the processes come at the same time. So shortest remaining time first works just like SJF, and SJF is optimal for average waiting time. With round robin, random order or "long jobs first", the short jobs have to wait more.
Answer: Shortest remaining time first
Answer: Shortest remaining time first