GATE 2005
203 questions
MCQ 2031-mark 203
Questions 136–140 of 203
Consider the languages:
,where # is a special symbol
Which one of the following is TRUE?
,where # is a special symbol
Which one of the following is TRUE?
Answer: (B)
- : the symbol marks the middle. A DPDA pushes the symbols of until it sees , then pops one symbol for each input symbol while matching . No guessing is needed, so is a deterministic CFL.
- : there is no marker, so the machine must guess where the middle is. This needs nondeterminism. It is a CFL but not a deterministic CFL, so (A) is false.
- : a stack gives the reverse of , not in the same order, so it cannot be matched. is not context-free at all (pumping lemma on ). So (C) and (D) are false.
Answer: (B)
- : there is no marker, so the machine must guess where the middle is. This needs nondeterminism. It is a CFL but not a deterministic CFL, so (A) is false.
- : a stack gives the reverse of , not in the same order, so it cannot be matched. is not context-free at all (pumping lemma on ). So (C) and (D) are false.
Answer: (B)
Consider the languages:
and
Which one of the following statements is FALSE?
and
Which one of the following statements is FALSE?
Answer: (A)
is a CFL. [Push the 's on the stack, and pop one for each .]
is a CFL. [Push the 's on the stack, and pop one for each .]
C) is True.
B) is True. CFL is closed under union. [ where is the grammar for and is the grammar for .]
CFL is not closed under intersection, so the intersection of two CFLs may or may not be a CFL. Let us check:
This is context sensitive but not context free. [One stack cannot match the 's, 's and 's together.]
So, A) is False.
D) is True.
Let L1 be a recursive language, and let L2 be a recursively enumerable but not a recursive language. Which one of the following is TRUE?
Answer: (B)
: is recursive, so some Turing machine M halts on every input and accepts exactly the words of . Swap its accept and reject answers: the new machine also halts on every input and accepts exactly the words not in . So is recursive.
: suppose were recursively enumerable. Then and would both be recursively enumerable. Run a machine for each on the same input in parallel. Exactly one of them accepts, so we would know the answer in finite time, and would be recursive. That contradicts the given fact. So is not recursively enumerable.
This rules out (A), (C) (they say is recursively enumerable) and (D) (it says is recursive).
Answer: (B)
: suppose were recursively enumerable. Then and would both be recursively enumerable. Run a machine for each on the same input in parallel. Exactly one of them accepts, so we would know the answer in finite time, and would be recursive. That contradicts the given fact. So is not recursively enumerable.
This rules out (A), (C) (they say is recursively enumerable) and (D) (it says is recursive).
Answer: (B)
Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is true?
Answer: (C)
A reduction means is at least as hard as : a decider for would give a decider for .
(A) only says is at least as hard as the decidable . can still be undecidable. False.
(B) says is no harder than the undecidable . may be decidable or undecidable. False.
(C) : if were decidable, would be decidable too, which is not so. So is undecidable. True.
(D) The complement of an undecidable problem is also undecidable, so again only says is no harder than an undecidable problem. It does not make decidable. False.
Answer: (C)
(A) only says is at least as hard as the decidable . can still be undecidable. False.
(B) says is no harder than the undecidable . may be decidable or undecidable. False.
(C) : if were decidable, would be decidable too, which is not so. So is undecidable. True.
(D) The complement of an undecidable problem is also undecidable, so again only says is no harder than an undecidable problem. It does not make decidable. False.
Answer: (C)
Consider the context-free grammar
where E is the starting symbol, the set of terminals is {id, (,+,),*}, and the set of non-terminals is {E}.
For the terminal string id + id + id + id, how many parse trees are possible?
where E is the starting symbol, the set of terminals is {id, (,+,),*}, and the set of non-terminals is {E}.
For the terminal string id + id + id + id, how many parse trees are possible?
Answer: (A)
The rule always produces parentheses, and the string has none. So only and are used. Then each parse tree is one way to group the four id's with three operators.
The number of ways is the Catalan number . The groupings, with the four id's called a, b, c, d:
Tree 1: (a+b)+(c+d)
Tree 2: a+(b+(c+d))
Tree 3: (a+(b+c))+d
Tree 4: a+((b+c)+d)
Tree 5: ((a+b)+c)+d
These five are all the groupings, so there are 5 parse trees.
Answer: (A)
The number of ways is the Catalan number . The groupings, with the four id's called a, b, c, d:
Tree 1: (a+b)+(c+d)
Tree 2: a+(b+(c+d))
Tree 3: (a+(b+c))+d
Tree 4: a+((b+c)+d)
Tree 5: ((a+b)+c)+d
These five are all the groupings, so there are 5 parse trees.
Answer: (A)