NPTEL Compiler Design Week 3 Assignment Answers 2024

Join Our WhatsApp Group Join Now
Join Us On Telegram Join Now

NPTEL Compiler Design Week 3 Assignment Answers 2024

1. Which of the following Machine model is usually used (at least implicitly) for parsing of strings?

(A) Finite state automaton
(B) Pushdown automaton
(C) Linear bounded automata
(D) None of the other options

Answer :- For Answer Click Here

2. A context free grammar (CFG) is treated as ambiguous when there exists a string in the language of the grammar which:

(A) can be generated by more than one leftmost derivation or more than one rightmost derivation
(B) cannot be generated by the grammar at all
(C) can be generated by both leftmost derivation and rightmost derivation
(D) can be generated by one leftmost derivation but cannot be generated by rightmost derivation

Answer :- For Answer Click Here

3. What is the language of the following finite automaton?

NPTEL Compiler Design Week 3 Assignment Answers 2024

(A) The set of all strings over the alphabet {a,b}
(B) The set of strings over the alphabet {a,b} with even number of a’s
(C) The set of strings over the alphabet {a,b} with even number of b’s
(D) None of the other options

Answer :- For Answer Click Here

4. What is the language of the following finite automaton?

NPTEL Compiler Design Week 3 Assignment Answers 2024

(A) The set of all strings over the alphabet {a,b} where each string has more than two a’s
(B) The set of all strings over the alphabet {a,b} where each string has equal number of a’s and b’s
(C) The set of all strings over the alphabet {a,b} where each string has exactly two a’s
(D) None of the other options

Answer :- 

5. What is the language of the following finite automaton?

NPTEL Compiler Design Week 3 Assignment Answers 2024

(A) The set of all strings over the alphabet {a,b} where each string has at least two a’s
(B) The set of all strings over the alphabet {a,b} where each string has more than two b’s
(C) The set of all strings over the alphabet {a,b} where each string has more than two a’s
(D) None of the other options

Answer :- 

6. What is the shortest string that is not a member of the language represented by the regular expression a*(ab)*b* (shortest in length)?

(A) aab
(B) bba
(C) ba
(D) bb

Answer :- For Answer Click Here

7. Given L={anbm| n, m > 0}, we define L’={wwR|w is a string of L}. Which of the following is true?

(A) L is regular but L’ is not regular
(B) Both L and L’ are regular
(C) L is not regular but L’ is regular
(D) None of the other options is true

Answer :- 

8. Which of the following grammars accepts strings over the alphabet set {a, b}, such that every a is immediately followed by one b?

(A) S → B | SabS; B → bB | ε
(B) S → B | SabS; B → aB | ε
(C) S → aB | SabS; B → bB | ε
(D) None of the other options

Answer :- 

9. Consider the grammar: S → aSa|bSb|a|b. The language generated by the above grammar is:

(A) The set of all palindromes over the alphabet {a,b}
(B) The set of all odd length palindromes over the alphabet {a,b}
(C) The set of all even length palindromes over the alphabet {a,b}
(D) None of the other options

Answer :- 

10. Consider the grammar given below with variable set {S, L} and the terminals {(, ), a, ,}.

     S –> (L) | a

     L –> L, S | S
    Which of the following strings will be accepted by the grammar?

(A) ((a, a), a)
(B) (a, a)
(C) ((a, a, a), a)
(D) All of the above

Answer :- For Answer Click Here

11. A parse tree shows which of the following properties?

(A) The terminals are always leaf nodes
(B) The intermediate nodes of the parse tree are always non-terminals
(C) The root of the tree is the start symbol of the grammar
(D) All of the above

Answer :- 

12. In which phase of the compilation process, parse tree is generated?

(A) Lexical analysis
(B) Syntax analysis
(C) Semantic analysis
(D) Intermediate code generation

Answer :- For Answer Click Here