This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Right Left Linear Grammar – 1”.
1. Non-Linear grammar has two non-terminals on the right-hand side.
a) True
b) False
View Answer
Explanation: The above stated grammar is non-linear because it has two non-terminals on the right-hand side.
2. Which type of grammar is it?
S → SS S → λ S → aSb S → bSa
a) Linear
b) Nonlinear
c) Linear & Nonlinear
d) None of the mentioned
View Answer
Explanation: Grammar is non-linear because one of the rules (the first one) has two non-terminals on the right-hand side.
3. Linear grammar has more than one non-terminal on the right-hand side.
a) True
b) False
View Answer
Explanation: Grammar is linear because no rule has more than one non terminal on the right-hand side.
4. In Right-Linear grammars, all productions have the form: A → xB.
a) True
b) False
View Answer
Explanation: Right-Linear grammars, following are the form of productions: A → xB or A → x where x is some string of terminals.
5. Which type of grammar is it?
S → abS S → a
a) Right Linear Grammar
b) Left Linear Grammar
c) Right & Left Linear Grammar
d) None of the mentioned
View Answer
Explanation: grammars in which all of the rules contain only one non-terminal on the left-hand side, and where in every case that non-terminal is the first symbol are called right Linear.
6. What are the two types of Linear Grammar?
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Right & Left Linear
View Answer
Explanation: Linear grammar is of 2 types Left and Right Linear Grammar
7. Which Grammar is it?
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Right & Left Linear
View Answer
Explanation: In Left-Linear grammars, all productions have the form: A→Bx or A→ x where x is some string of terminals.
8. Which Type of Grammar is it?
S → Aa A → Aab | λ
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Right & Left Linear
View Answer
Explanation: In this case they both correspond to the regular expression (ab)*a.
9. A Regular Grammar is any right-linear or left-linear grammar.
a) True
b) False
View Answer
Explanation: As it turns out the languages that can be generated by Regular Grammars is equivalent to those that can be specified by Regular Expressions.
10. Regular Grammars generate Regular Languages.
a) True
b) False
View Answer
Explanation: That’s why they are called regular languages.
Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Apply for Computer Science Internship
- Check Compiler Design Books
- Practice MCA MCQs
- Practice Computer Science MCQs