Theory of computation miscellaneous
- Which one of the following grammars is free from left recursion?
-
View Hint View Answer Discuss in Forum
Grammar A has direct left recursion because of the production rule : A → Aa. Grammar C has indirect left recursion because of the production rules : S → Aa and A → Sc Grammar D has indirect left recursion because of production rules : A → Bd and B → Ae Grammar B doesn't have any left recursion (neither direct nor indirect).
Correct Option: B
Grammar A has direct left recursion because of the production rule : A → Aa. Grammar C has indirect left recursion because of the production rules : S → Aa and A → Sc Grammar D has indirect left recursion because of production rules : A → Bd and B → Ae Grammar B doesn't have any left recursion (neither direct nor indirect).
- Language L1 is defined by the grammar: S1 → aS1 b | ε
Language L2 is defined by the grammar: S2 → abS2 | ε
Consider the following statements:
P : L1 is regular
Q : L2 is regular
Which one of the following is TRUE?
-
View Hint View Answer Discuss in Forum
L1 has the property that no. of a’s should be equal to no. of b’s in a string, and all a’s should precede all b’s. Hence extra memory will be required to check this property of a string (Finite Automata can't be built for this type of language). Hence this is not regular language. Therefore P is False. L2 has the property that no. of a’s should be equal to no. of b’s, but order of a’s and b’s is different here, it is (ab)*, which will require no extra memory to be accepted. (Finite Automata can be built for this language). Hence L2 is regular language. Therefore Q is True.
Correct Option: C
L1 has the property that no. of a’s should be equal to no. of b’s in a string, and all a’s should precede all b’s. Hence extra memory will be required to check this property of a string (Finite Automata can't be built for this type of language). Hence this is not regular language. Therefore P is False. L2 has the property that no. of a’s should be equal to no. of b’s, but order of a’s and b’s is different here, it is (ab)*, which will require no extra memory to be accepted. (Finite Automata can be built for this language). Hence L2 is regular language. Therefore Q is True.
- Consider the transition diagram of a PDA given below with input alphabet ∑ = {a, b} and stack alphabet Γ = {X, Z}. Z is the initial stack symbol. Let L denote the language accepted by the PDA.
Which one of the following is TRUE?
-
View Hint View Answer Discuss in Forum
Initial state is also the final state. So an is also accepted.
Correct Option: D
Initial state is also the final state. So an is also accepted.
- Consider the following context-free grammars:
G1 : S → aS | B, B → b | bB
G2 : S → aA | bB, A → aA | B | ε , B → bB | ε
Which one of the following pairs of languages is generated by G1 and G2, respectively?
-
View Hint View Answer Discuss in Forum
In G1, there will be atleast 1 b because S->B and B->b. But no. of A's can be 0 as well and no. of A and B are independent. In G2, either we can take S->aA or S- >bB. So it must have atleast 1 a or 1 b. So option (d) is correct.
Correct Option: D
In G1, there will be atleast 1 b because S->B and B->b. But no. of A's can be 0 as well and no. of A and B are independent. In G2, either we can take S->aA or S- >bB. So it must have atleast 1 a or 1 b. So option (d) is correct.
- 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 x ∈ ∑*, does x ∈ L(G) ?
III. Given CFGs G1 and G2 is L(G1) = L(G2)?
IV. Given a TM M, is L(M) = Φ ?
-
View Hint View Answer Discuss in Forum
There is no known algorithm to verify whether the language accepted by TM is empty or not. Similarly there is no algorithm to verify whether language of CFG’s are equivalent.
Correct Option: C
There is no known algorithm to verify whether the language accepted by TM is empty or not. Similarly there is no algorithm to verify whether language of CFG’s are equivalent.