GATE 2007
184 questions
MCQ 1841-mark 184
Questions 111–115 of 184
Consider the following DFA in which is the start state and , are the final states
What language does this DFA recognize?
What language does this DFA recognize?
Answer: (D)
Name each state , where is the number of y's mod 2 and is the number of x's mod 2. Reading x flips and reading y flips .
(Same DFA, redrawn with the state names .)
Matching with the given DFA: (x even, y even), (x odd, y even), (x even, y odd) and (x odd, y odd). Check: goes to on x and to on y; goes to on y; goes to on x.
The final states are and , so exactly one of the two counts is odd. The language is: even number of x and odd number of y, or odd number of x and even number of y.
(A) is wrong, since the empty string ends in , which is not final. (B) describes and , which are not final. (C) is wrong, since xy has one x and one y but ends in .
Answer: (D)
(Same DFA, redrawn with the state names .)
Matching with the given DFA: (x even, y even), (x odd, y even), (x even, y odd) and (x odd, y odd). Check: goes to on x and to on y; goes to on y; goes to on x.
The final states are and , so exactly one of the two counts is odd. The language is: even number of x and odd number of y, or odd number of x and even number of y.
(A) is wrong, since the empty string ends in , which is not final. (B) describes and , which are not final. (C) is wrong, since xy has one x and one y but ends in .
Answer: (D)
Consider the following Finite State Automaton:
The minimum state automaton equivalent to the above FSA has the following number of states
The minimum state automaton equivalent to the above FSA has the following number of states
Answer: (B)
Step 1: has no incoming edge, so the start state can never reach it. Remove it.
Step 2: and are both final. On a each goes to the other, and on b each stays in itself, so from either one every string leads only to states in , all of which are final. No string tells them apart, so merge them. is not final, so it cannot be merged with them.
In the figure below, q0 is and q1 is the merged state .
The same 2-state automaton again, redrawn:
The minimum automaton has 2 states.
Answer: (B)
Step 2: and are both final. On a each goes to the other, and on b each stays in itself, so from either one every string leads only to states in , all of which are final. No string tells them apart, so merge them. is not final, so it cannot be merged with them.
In the figure below, q0 is and q1 is the merged state .
The same 2-state automaton again, redrawn:
The minimum automaton has 2 states.
Answer: (B)
Consider the following Finite State Automaton:
The language accepted by this automaton is given by the regular expression
The language accepted by this automaton is given by the regular expression
Answer: (C)
State has no incoming edge, so it is never reached. From the start state , b keeps the machine in and the first a moves it to . is not final, so a string needs at least one a. After that, the machine stays in for both a and b, and both these states are final, so every continuation is accepted.
So the language is: any number of b's, then an a, then any string, which is .
(A) and (D) need at least three or two a's, but a alone is accepted. (B) includes and b, which are rejected.
Answer: (C)
So the language is: any number of b's, then an a, then any string, which is .
(A) and (D) need at least three or two a's, but a alone is accepted. (B) includes and b, which are rejected.
Answer: (C)
A minimum state deterministic finite automaton accepting the language L={w|w {0,1}*} , number of 0s and 1s in w are divisible by 3 and 5, respectively has
Answer: (A)
Track the pair (, ). It has values, and each is reachable (for example by ). A DFA that moves between these pairs on each input symbol accepts L, with as the start and only final state. So 15 states are enough.
None can be merged. Take two different pairs and . Append the string . The first pair becomes and is accepted. The second becomes , which is not , so it is rejected. So all 15 states are pairwise distinguishable, and by the Myhill-Nerode theorem the minimum is 15.
Answer: (A)
Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
Answer: (C)
P is false. Take . It is a regular grammar. Both productions start with , so with one symbol of lookahead an LL(1) parser sees and cannot choose between them. So not every regular grammar is LL(1).
Q is true. Every regular language is a deterministic context-free language (a DFA is a DPDA that never uses its stack). Every deterministic context-free language has an LR(1) grammar. So every regular set has an LR(1) grammar.
Answer: (C)
Q is true. Every regular language is a deterministic context-free language (a DFA is a DPDA that never uses its stack). Every deterministic context-free language has an LR(1) grammar. So every regular set has an LR(1) grammar.
Answer: (C)