This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Context free Grammar – 1”.

1. Assume the statements S1 and S2 given as:

S1: Given a context free grammar, there exists an algorithm for determining whether L (G) is infinite.

S2: There exists an algorithm to determine whether two context free grammars generate the same language.

Which of the following is true?

a) S1 is correct and S2 is not correct

b) Both S1 and S2 are correct

c) Both S1 and S2 are not correct

d) S1 is not correct and S2 is correct

View Answer

Explanation: The proof of S1 can be seen in various book of theory of computation but s2 is a problem of category undecidable so a contradiction to this assumption can be easily obtained.

2. If P & R are regular and also given that if PQ=R, then

a) Q has to be regular

b) Q cannot be regular

c) Q need not be regular

d) Q has to be a CFL

View Answer

Explanation: If two regular languages when combined do not always produce a regular language.

3. Which of the following conversion is not possible (algorithmically)?

a) Regular grammar to CFG

b) NDFA to DFA

c) NDPDA to DPDA

d) NDTM to DTM

View Answer

Explanation: Not every NDPDA has an equivalent deterministic PDA.

4. Consider the grammar given below E? E+E | E*E | E-E | E/E | E^E | (E) | id Assume that + and ^ have the same but least precedence, * and / have the next higher precedence but the same precedence and finally ^ has the highest precedence. Assume + and ^ associate to the left like * and / and that ^ associates to the right. Choose the correct for the ordered pairs (^,^) , (-,-) , (+,+) , (*,*) in the operator precedence table constructed for the grammar

a) All <

b) All >

c) < > , =

d) < > > >

View Answer

Explanation: This relation is established of basis of the precedence of operators.

5. Recursively enumerable languages are not closed under:

a) Union

b) Intersection

c) Complementation

d) Concatenation

View Answer

Explanation: Recursive languages are closed under the following operations.

The Kleene star L * of L

the concatenation L * o P of L and P

the union L U P

the intersection L ∩ P.

6. Grammar that produce more than one Parse tree for same sentence is:

a) Ambiguous

b) Unambiguous

c) Complementation

d) Concatenation Intersection

View Answer

Explanation: an ambiguous grammar is one for which there is more than one parse tree for a single sentence.

7. Automaton accepting the regular expression of any number of a ‘ s is:

a) a*

b) ab*

c) (a/b)*

d) a*b*c

View Answer

Explanation: It gives any number of a’s.

8. Grammars that can be translated to DFAs:

a) Left linear grammar

b) Right linear grammar

c) Generic grammar

d) All of the mentioned

View Answer

Explanation: Right linear grammar can be translated to the DFAs.

9. The language accepted by a Push down Automata:

a) Type0

b) Type1

c) Type2

d) Type3

View Answer

Explanation: A known fact that type 2 grammar is accepted by PDA.

10. Given the following statements: (i) Recursive enumerable sets are closed under complementation. (ii) Recursive sets are closed under complements. Which is/are the correct statements?

a) I only

b) II only

c) Both I and II

d) Neither I nor II

View Answer

Explanation: Recursive languages are closed under the following operations.

The Kleene star L * of L

the concatenation L * o P of L and P

the union L U P

the intersection L ∩ P.

**Sanfoundry Global Education & Learning Series – Compilers.**

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