This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Regular Grammar – 2”.
1. Give a production grammar that specified language L = {ai b2i >= 1}.
a) {S->aSbb,S->abb}
b) {S->aSb, S->b}
c) {S->aA,S->b,A->b}
d) None of the mentioned
View Answer
Explanation: S->aSbb, S->abb give a^I a’s and b^2i b’s.
2. Let R1 and R2 be regular sets defined over alphabet ∑ then?
a) R1 UNION R2 is regular
b) R1 INTERSECTION R2 is regular
c) ∑ INTERSECTION R2 IS NOT REGULAR
d) R2* IS NOT REGULAR
View Answer
Explanation: Union of 2 regular languages is regular.
3. Which of the following String can be obtained by the language L = {ai b2i / i >=1}?
a) aaabbbbbb
b) aabbb
c) abbabbba
d) aaaabbbabb
View Answer
Explanation: Above production rule gives suppose if 3 a’s the corresponding b’s are 6 b’s.
4. Give a production grammar for the language L = {x/x ∈ (a,b)*, the number of a’s in x is multiple of 3}.
a) {S->bS, S->b,S->aA, S->bA, A->aB, B->bB, B->aS, S->a}
b) {S->aS,S->bA,A->bB,B->bBa,B->bB}
c) {S->aaS,S->bbA,A->bB,B->ba}
d) None of the mentioned
View Answer
Explanation: The above given condition is satisfied by
S->bS S->B
S->aA s->bA A->aB B->bB
B->aS S->a.
5. The production Grammar is {S->aSbb, S->abb} is?
a) type-3 grammar
b) type-2 grammar
c) type-1 grammar
d) type-0 grammar
View Answer
Explanation: Type 2 grammar satisfies this production grammar.
6. The regular expression denote a language comprising all possible strings of even length over the alphabet (0,1) is?
a) 1 + 0(1+0)*
b) (0+1)(1+0)*
c) (1+0)
d) (00+0111+10)*
View Answer
Explanation: The condition is satisfied by 00 or 0111 or 10 or iterations of these.
Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice MCA MCQs
- Practice Computer Science MCQs
- Check Computer Science Books
- Check Compiler Design Books
- Apply for Computer Science Internship