# 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

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

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

Q4. Two important lexical categories are ___________.

a) White space
c) None of the mentioned

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

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

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

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

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

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

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

### 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

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

Q3.

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

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

Q5. Between NFA and DFA which one is more powerful

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

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

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

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

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

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

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

<< 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 – 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.