Regular Grammar · Theory of Computation
6 questions · asked in 5 of 27 years (2000–2026)
MCQ 61-mark 5 · 2-mark 1
2000Questions per year2026
Questions 1–5 of 6
Consider the alphabet ={0, 1}, the null/empty string and the sets of strings generated by the corresponding non-terminals of a regular grammar. are related as follows.
Which one of the following choices precisely represents the strings in ?
Which one of the following choices precisely represents the strings in ?
Answer: (C)
Put into :
Substitution step:
Now use Arden's rule: , and so .
Answer: 1(0 + 10)*1
Substitution step:
Now use Arden's rule: , and so .
Answer: 1(0 + 10)*1
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)
Consider the regular grammar below
The Myhill-Nerode equivalence classes for the language generated by the grammar are
The Myhill-Nerode equivalence classes for the language generated by the grammar are
Answer: (A)
Two strings are in the same Myhill-Nerode class if no suffix z can tell them apart, that is, xz is in the language exactly when yz is. The classes correspond to the states of the minimal DFA, and each class is the set of strings that lead from the start state to that state.
The grammar gives this DFA (S is the start and final state):
b does not change the state, and a switches between S and A. So S is reached by strings with an even number of a's, A by strings with an odd number of a's, and the language is . The DFA is minimal, because S is final and A is not, so the empty suffix separates them. So there are exactly two classes: even number of a's and odd number of a's.
Why the others fail:
- (B) The string "b" has an even number of a's and an odd number of b's, so it is in both sets. Classes cannot overlap.
- (C) The empty string and "ab" both have equal numbers of a and b, but adding "a" gives "a" (not in the language) and "aba" (in the language).
- (D) The empty string and "bb" are in the same class (both have zero a's), but (D) separates them.
Answer: (A)
The grammar gives this DFA (S is the start and final state):
b does not change the state, and a switches between S and A. So S is reached by strings with an even number of a's, A by strings with an odd number of a's, and the language is . The DFA is minimal, because S is final and A is not, so the empty suffix separates them. So there are exactly two classes: even number of a's and odd number of a's.
Why the others fail:
- (B) The string "b" has an even number of a's and an odd number of b's, so it is in both sets. Classes cannot overlap.
- (C) The empty string and "ab" both have equal numbers of a and b, but adding "a" gives "a" (not in the language) and "aba" (in the language).
- (D) The empty string and "bb" are in the same class (both have zero a's), but (D) separates them.
Answer: (A)
Consider the regular grammar:
where S is the starting symbol, the set of terminals is {a} and the set of non-terminals is {S, W, X, Y, Z}.
We wish to construct a deterministic finite automaton (DFA) to recognize the same language. What is the minimum number of states required for the DFA?
where S is the starting symbol, the set of terminals is {a} and the set of non-terminals is {S, W, X, Y, Z}.
We wish to construct a deterministic finite automaton (DFA) to recognize the same language. What is the minimum number of states required for the DFA?
Answer: (B)
Every rule has the form (non-terminal)a, a or , so the grammar is left linear. Substitute step by step:
and give .
and give .
So becomes .
So . The only terminal is .
and give .
and give .
So becomes .
So . The only terminal is .
Reversing every right-hand side gives a right linear grammar for . Here , because every string is a power of . Its NFA is:
The DFA for (states S, XY, ZW):
The DFA for , with all arrows reversed:
The DFA keeps , so it has 3 states. It cannot have fewer, because , and are pairwise distinguishable. is accepted and the other two are not. Adding one gives (accepted) from , but (rejected) from .
Answer: (B)
Consider the following grammar G:
Let Na(w) and Nb(w) denote the number of a's and b's in a string w respectively.
The language generated by G is
S → bS | aA | b
A → bA | aB
B → bB | aS | aLet Na(w) and Nb(w) denote the number of a's and b's in a string w respectively.
The language generated by G is
Answer: (C)
Read the non-terminals as states that track the number of 's read so far, modulo 3:
: count , : count , : count .
Each keeps the state (, , ). Each moves . The only ways to stop are and , and both end back in state . So a string is generated exactly when it is non-empty and its number of 's is a multiple of 3.
Check: comes from . comes from .
The string has , so it is not in (A), and is not a multiple of 3, so it is not in (D). The string has , so it is not in (B).
Answer: (C)
: count , : count , : count .
Each keeps the state (, , ). Each moves . The only ways to stop are and , and both end back in state . So a string is generated exactly when it is non-empty and its number of 's is a multiple of 3.
Check: comes from . comes from .
The string has , so it is not in (A), and is not a multiple of 3, so it is not in (D). The string has , so it is not in (B).
Answer: (C)
Keep practising