Compilers Questions and Answers – Regular Grammar – 2

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

Answer: a
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

Answer: a
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

Answer: a
Explanation: Above production rule gives suppose if 3 a’s the corresponding b’s are 6 b’s.
advertisement
advertisement

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

Answer: a
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

Answer: b
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

Answer: d
Explanation: The condition is satisfied by 00 or 0111 or 10 or iterations of these.

Sanfoundry Global Education & Learning Series – Compilers.

advertisement

To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.