This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Code Generation – 1”.
1. Grammar that produce more than one Parse tree for same sentence is
d) Concatenation Intersection
Explanation: An ambiguous grammar is one for which there is more than one parse tree for a single sentence.
2. Automaton accepting the regular expression of any number of a ‘ s is
Explanation: It gives any number of a’s.
3. Grammars that can be translated to DFAs:
a) Left linear grammar
b) Right linear grammar
c) Generic grammar
d) All of the mentioned
Explanation: Right linear grammar can be translated to the DFAs.
4. The language accepted by a Push down Automata
Explanation: A known fact that type 2 grammar is accepted by PDA.
5. 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
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. Assume statements S1 and S2 defined as : S1 : L2-L1 is recursive enumerable where L1 and L2 are recursive and recursive enumerable respectively. S2 : The set of all Turing machines is countable. 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.
Explanation: The assumptions of statement S1 and S2 are correct.
7. A context free language is called ambiguous if
a) It has 2 or more left derivations for some terminal string ѡ є L (G)
b) It has 2 or more right derivations for some terminal string ѡ є L (G)
c) Both of th ementioned
d) None of the mentioned
Explanation: A context-free grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings.
Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.