Compiler Design | NPTEL 2023 | Week 2 Assignment Solutions

This set of MCQ(multiple choice questions) focuses on the Compiler Design NPTEL 2023 Week 2 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 2022 Week 1 Assignment Solution” contains 11 questions.

Now, start attempting the quiz.

Compiler Design NPTEL 2023 Week 2 Assignment Solutions

Q1. The output of lexical analyzer is

a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character

Answer: c) Set of Tokens

Q2. A regular expression represents

a) Part of a language
b) Cannot represent any language
c) Constituent strings of a language
d) None of the other options

Answer: c) Constituent strings of a language

Q3. When expression sum=3+2 is tokenized then what is the token category of 3

a) Identifier
b) Assignemnt operator
c) Integer literal
d) Addition operator

Answer: c) Integer literal

Q4. Two important lexical categories are ___________.

a) White space
b) Comments
c) None of the mentioned
d) White space & comments

Answer: d) White space & comments

Q5. For the Fortran language statement “DO 5 I = 1.25” returns token IDENTIFIER for DO 5 I after looking upto

a) I
b) =
c) .
d) 5

Answer: c) .

Compiler Design NPTEL week 2 Assignment Solutions

Q6. The regular expression (0|1)*(0|1) represents a language with

a) Nonempty binary strings
b) Empty and nonempty binary strings
c) Odd nonempty strings
d) Even nonempty strings

Answer: a) Nonempty binary strings

Q7. L((r)+) is equivalent to

a) L((r)+) = L((r)*) = {e}
b) L((r)+) = L((r)*)
c) L((r)+) = {e}
d) L((r)+) = L((r))

Answer: a) L((r)+) = L((r)*) = {e}

Compiler Design NPTEL week 2 Assignment Solutions

Q8. A regular expression for accepting strings with exactly one 1 more than 0’s is

a) 0*1
b) (0|1)*1(0|1)*
c) (0|1)*1(0|1)*|1(0|1)*
d) Not possible

Answer: d) Not possible

Compiler Design NPTEL week 2 Assignment Solutions

Q9. A DFA cannot have

a) Epsilon transitions
b) An isolated state
c) More than one transition from a state on same in out
d) All of the other options

Answer: d) All of the other options

Q10. Number of possible epsilon transitions from a state in an NFA is

a) One
b) At most one
c) Many
d) Zero

Answer: c) Many

Compiler Design NPTEL week 2 Assignment Solutions

Q11. The regular expression: 0*10*10*10* is the representation of which following language over the alphabet {0,1}?

a) All binary strings possessing exactly three 1’s
b) All binary strings possessing more than three 1’s
c) All binary strings possessing less than three 1’s
d) None of the above

Answer: a) All binary strings possessing exactly three 1’s

Q12. The _________ of a set of states, P, of an NFA is defined as the set of states reachable from any state in P following e-transitions

a) e-closure
b) e-park
c) Q in the tuple
d) None of the mentioned

Answer: a) e-closure

Q13. A certain compiler corrects errors like “fi” to “if” automatically. This is an example of recovery in

a) Panic mode
b) Delete character
c) Replace Character
d) Transpose character

Answer: d) Transpose character

Q14. The total number of states to build the given language using DFA:
L = {w|w has exactly 2 a’s and at least 2 b’s}

a) 10
b) 11
c) 12
d) 13

Answer: a) 10

Compiler Design NPTEL 2022 Week 2 Assignment Solutions

Q1. When the lexical analyzer reads the source code, it scans the code

a) Line-by-line
b) Word-by-word
c) Letter-by-letter
d) Whole at a time

Answer: c)

Q2. The regular expression for strings (over alphabet set {0, 1}) in which a ‘0’ is always followed by at least two 1’s (that is “11”) is

a) (1*(011)*)*
b) 1*(011)*
c) Not possible to create such a regular expression
d) None of the other options

Answer: a)

Q3.

Answer: b)

Q4. The number of possible epsilon transitions from a state in an NFA is

a) Many
b) At most one
c) One
d) Zero

Answer: a)

Q5. Between NFA and DFA which one is more powerful

a) NFA
b) DFA
c) both are powerful
d) Cannot be said definitely

Answer: c)

Compiler Design NPTEL week 2 Assignment Solutions

Q6. A regular expression represents

a) Cannot represent any language
b) Part of a language
c) Constituent strings of a language
d) None of the other options

Answer: c)

Q7. Finite automata is an implementation of

a) Part of a Regular expression
b) Any grammar
c) Regular expression
d) None of the other options

Answer: c)

Compiler Design NPTEL week 2 Assignment Solutions

Q8. Which is easier to implement, the NFA or the DFA?

a) NFA
b) DFA
c) Equal effort needed
d) Cannot be said definitely

Answer: a)

Compiler Design NPTEL week 2 Assignment Solutions

Q9. The regular expression (0|1)*00 will accept all strings

a) Divisible by 2
b) Divisible by 4 with minimum length 2
c) Divisible by 2 with minimum length 2
d) Divisible by 4

Answer: b)

Q10. What exactly is a lexeme?

a) Any sequence of characters
b) Sequence of characters defining a token
c) Same as a token
d) Not related to any token

Answer: b)

Compiler Design NPTEL week 2 Assignment Solutions

Q11. Output of the tool lex is

a) A C program
b) An executable code
c) A parser
d) None of the other options

Answer: a)

<< Prev- Compiler Design Week 1 Assignment Solutions

>> Next- Compiler Design Week 3 Assignment Solutions


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

The above question set contains all the correct answers. But in any case, you find any typographical, grammatical or any other error in our site then kindly inform us. Don’t forget to provide the appropriate URL along with error description. So that we can easily correct it.

Thanks in advance.

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 *