Compiler Design | NPTEL 2023 | Week 4 Assignment Solutions

This set of MCQ(multiple choice questions) focuses on the Compiler Design NPTEL 2023 Week 4 Assignment Solutions.

Course layout

Answers COMING SOON! Kindly Wait!

Week 1: Assignment answers
Week 2: Assignment answers
Week 3: Assignment answers
Week 4: Assignment answers
Week 5: Assignment answers
Week 6: Assignment answers
Week 7: Assignment answers
Week 8: Assignment answers
Week 9: Assignment answers
Week 10: Assignment answers
Week 11: Assignment answers
Week 12: Assignment answers

NOTE: You can check your answer immediately by clicking show answer button. This set of “Compiler Design NPTEL 2023 Week 4 Assignment Solution” contains 10 questions.

Now, start attempting the quiz.

Compiler Design NPTEL 2023 Week 4 Assignment Solutions

Q1. A grammar is ambiguous if

a) its left most and right most derivations are different
b) more than one left most derivations exist
c) there is not left most derivation
d) there is no rightmost derivation

Answer: b) more than one left most derivations exist

Q2. An ambiguous grammar has the potential to produce multiple parse trees for

a) Unique input string
b) Multiple input strings
c) At most two input strings
d) None of the other options

Answer: b) Multiple input strings

Q3. For the grammar given below, number of parse trees to produce an empty string is
A AA | (A) | e

a) One
b) Two
c) Infinite
d) None of the other options

Answer: c) Infinite

Q4. A predictive parser

a) Needs backtracking
b) Does not need backtracking
c) May not terminate
d) None fo the other options

Answer: b) Does not need backtracking

Q5. Which of the following grammar rules is/are left recursive?

a) A Aa|b
b) A Bb, B Aa |c
c) A Ba, B Cc, C Ac
d) All of the other options

Answer: d) All of the other options

Compiler Design NPTEL week 4 Assignment Solutions

Q6. For the grammar rules {S â†’ Aa | bB, A â†’ c|e}, FIRST(S) is

a) {b, c}
b) {a, b}
c) {a, b, c}
d) {a, b, c, e}

Answer: c) {a, b, c}

Q7. What is the purpose of error handler?

a) The processing of correct programs should have minimum overhead
b) Reporting the presence of errors accurately
c) Recover quickly from one error in order to detect the next one
d) All of the above

Answer: d) All of the above

Compiler Design NPTEL week 4 Assignment Solutions

Q8. Match the columns according the error recovery strategies –

P) Global correctionW) Augment the grammar with productions that generate the erroneous constructs
Q) Phrase level recoveryX) Choosing minimal sequence of changes to obtain a globally least-cost correction
R) Error productionsY) Discard input symbol one at a time until one of designated set of synchronization tokens is found
S) Panic mode recoveryZ) Replacing a prefix of remaining input by some string that allows the parser to continue

a) P-X, Q-Y, R-Z, Q-W
b) P-Z, Q-X, R-Y, S-W
c) P-X, Q-Z, R-W, S-Y
d) P-W, Q-X, R-Y, S-Z

Answer: c) P-X, Q-Z, R-W, S-Y

Compiler Design NPTEL week 4 Assignment Solutions

Q9. Select the correct statement.

a) General recursive descent never requires backtracking
b) Recursive descent parsers cannot be used for left-recursive grammars
c) A top-down parser tries to create a parse tree from the leaf towards the root
d) All of the above

Answer: b) Recursive descent parsers cannot be used for left-recursive grammars

Q10. In _______, if one derivation of a production fails, the syntax analyzer restrats the process using different rules of same production.

a) Bottom-up Parsing
b) Recursive descent parsing
c) Backtracking
d) All of the above

Answer: c) Backtracking

Compiler Design NPTEL week 4 Assignment Solutions

Q11. Non-recursive predictive grammar parsing incudes the following steps –
P: The transition diagram is parsed if it reaches the accept state
Q: Simulate the string on the transition diagram to parse the string
R: For every rule of grammar, making the transition diagram
S: Optimize the transition diagram by reducing the total number of states
In which order the steps are executed?
(If A should occur before B, then the notation is A>B)

a) P>R>S>Q
b) R>S>Q>P
C) R>S>P>Q
d) P>R>Q>S

Answer: b) R>S>Q>P

Q12. Which of the following suffices to convert an arbitrary cotext free grammar to an LL(1) grammar?

a) Removing left recursion only
b) Factoring the grammar alone
c) Factoring & left recursion removal
d) None of the mentioned

Answer: d) None of the mentioned

Q13. A form of recursive-descent parsing that does not require any back-tracking is known as?

a) predictive parsing
b) non-predictive parsing
c) recursive parsing
d) non-recursive parsing

Answer: a) predictive parsing

Compiler Design NPTEL 2022 Week 4 Assignment Solutions

Q1. Language accepted by a push down automata is

a) Context sensitive
b) Context free
c) Regular
d) None of the other options

Answer: b)

Q2. An ambiguous grammar has the potential to produce multiple parse trees for

a) Unique input string
b) Multiple input strings
c) At most two input strings
d) None of the other options

Answer: a)

Q3. For the grammar given below, number of parse trees to produce an empty string is
A AA | (A) |E

a) One
b) Two
c) Infinite
d) None of the other options

Answer: c)

Q4. For the grammar given below, FOLLOW(B) is
S a A b B | b A a B | E
A S
B S

a) {a, b}
b) {a, b, $}
c) Φ
d) None of the other options

Answer: b)

Q5. Activation records for recursive programs are created in

a) Stack segment
b) Data segment
c) Code segment
d) None of the other options

Answer: a)

Compiler Design NPTEL week 4 Assignment Solutions

Q6. Which of the following grammar rules is/are left recursive?

a) A Aa|b
b) A Bb, B Aa|c
c) A Ba, B Cc, C Ac
d) All of the other options

Answer: d)

Q7. Words of a language constitute

a) Set of terminals
b) Set of nonterminals
c) Set of both terminals and nonterminals
d) None of the other options

Answer: a)

Compiler Design NPTEL week 4 Assignment Solutions

Q8. The grammar {E → E + T | T, T → T * F | F, F → id} is

a) Ambiguous
b) Unambiguous
c) Partially ambiguous
d) None of the other options

Answer: b)

Compiler Design NPTEL week 4 Assignment Solutions

Q9. The grammar {E → E | E * E | id} is

a) Ambiguous
b) Unambiguous
c) Partially ambiguous
d) None of the other options

Answer: a)

Q10. For a context-free grammar, left-hand side of production rules should contain

a) Single nonterminal
b) Atmost three grammar symbols
c) Atmost two grammar symbols
d) None of the other options

Answer: a)

Q11. A grammar is ambiguous if

a) its left most and right most derivations are different
b) more than one left most derivations exist
c) there is no left most derivation
d) there is no rightmost derivation

Answer: b)

Q12. A grammar with production rules { A → Ba | Cb, B → CA, C → c | E} contains

a) Left factor
b) Left recursion
c) Both left factor and left recursion
d) None of the other options

Answer: b)

Q13. For top-down parsing left recursion removal is

a) Mandatory
b) Desirable
c) Too complex
d) Not needed

Answer: a)

Q14. Derivation produced by a top-down parser is

a) Leftmost
b) Rightmost
c) Either leftmost or rightmost
d) None of the other options

Answer: a)

Q15. A predictive parser

a) Needs backtracking
b) Does not need backtracking
c) May not terminate
d) None of the other options

Answer: b)

Compiler Design NPTEL week 4 Assignment Solutions

Q16. For the grammar rules {S → Aa | bB, A → c | E}, FIRST(S) is

a) {b, c}
b) {a, b}
c) {a, b, c}
d) {a, b, c, E}

Answer: c)

<< Prev- Compiler Design Week 3 Assignment Solutions

>> Next- Compiler Design Week 5 Assignment Solutions


DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.

NPTEL answers: Problem solving through programming in C

Programming in Java NPTEL week 1 quiz answers

NPTEL – Python for Data Science assignment solutions

Nptel – Deep Learning assignment solutions

For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.

Leave a Comment

Your email address will not be published. Required fields are marked *