Compiler Design Week 2 Nptel Assignment Answers
Are you looking for Compiler Design Week 2 Nptel Assignment Answers? You’ve come to the right place! Access the most accurate answers at Progiez.
Table of Contents
Compiler Design Week 2 Nptel Assignment Answers (Jan-Apr 2026)
Que.1
Assume that letter_ → [A-Za-z_] and digit → [0-9]. What is the correct regular expression to define a valid identifier in C programming language?
a) letter_(letter_| digit)*
b) (letter| digit)*
c) letter_(letter| digit)*
d) letter(letter | digit)*
Que.2
Consider the alphabet Σ = {a, b}. Which of the following is a correct regular expression that represents even number of a?
a) (babab*)* + (bb*)
b) (aba) + (bb*)
c) (babab*)*
d) (ababa*)* + (bb*)
Que.3
What is the regular expression over the Σ = {a, b} for the language that includes the strings containing ab as substring?
a) (a+b)ab(a+b)
b) (a+b)ab(a+b)
c) (ab)ab(ab)
d) ab(a+b)*
Que.4
Consider the following Deterministic Finite Automata (DFA). It represents:
a) A DFA that accepts all the strings that end with ba
b) A DFA that accepts all the strings that end with a
c) A DFA that accepts all the strings that end with b
d) An NFA that accepts all the strings that end with ab
Que.5
Which of the following statements about ε-moves (epsilon transitions) in finite automata is correct?
a) An ε-move consumes one input symbol from the alphabet
b) ε-moves are allowed only in DFA
c) ε-moves allow the automaton to change states without consuming any input symbol
d) An automaton with ε-moves always accepts all input strings
Que.6
Assume that the token set is {+, -, *, ++, –, **, >, <=, >=}. How many tokens can be generated for the input:
>=>++><=">>--
a) 10
b) 11
c) 12
d) 14
Que.7
What is the regular expression accepted by the following DFA?
a) 0(10)*
b) 01)*0
c) Both (a) and (b)
d) Neither (a) nor (b)
Que.8
Consider the grammar G with productions
S → aSb | ab, where S is the non-terminal and a and b are the terminal symbols.
G represents which language?
a) L(G) = {aⁿbⁿ : n ≥ 1}
b) L(G) = {aᵐbⁿ : m, n ≥ 1}
c) L(G) = {aⁿ : n > 1}
d) L(G) = {aᵐbⁿ : n ≥ 1, m < n}
Que.9
Consider the following C program segment:
void main()
{
int 1x, y;
x = 10;
y = a5;
if x > y
y = y + x;
}
This program suffers from:
a) One syntax error
b) One lexical error
c) Both (a) and (b)
d) Neither (a) nor (b)
Que.10
How many states will the DFA equivalent to an NFA with n states have in the worst case?
a) n
b) 2ⁿ
c) n²
d) n!
(Jan-Apr 2025)
Course Link: Click Here
1. 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
2. When expression sum=3+2 is tokenized then what is the token category of 3
a) Identifier
b) Assignment operator
c) Integer literal
d) Addition operator
3. For the Fortran language statement “DO 5 1 = 1.25” returns token IDENTIFIER for DO 5
I after looking upto
a) 1
b) =
c) •
d) 5
4. Which of the following are Lexemes?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
5. A regular expression for accepting strings with exactly one 1 more than O’s is
a) 01
b) (0|1)*1(0|1)*
c) (0|1)*1(0|1)*|1(0|1)*
d) Not Possible
6. Which one of the following languages over the alphabet (0,1} is described by the regular
expression: (0+1)*0(0+1)*0(0+1)*
a) The set of all strings containing the substring 00.
b) The set of all strings containing at most two O’s.
C) The set of all strings containing at least two O’s.
d) The set of all strings that begin and end with either 0 or 1.
7. Finite automata is an implementation of
a) Regular expression
b) Any grammar
c) Part of the regular expression
d) None of the other options
8. The automation which allows transformation to a new state without consuming any input
symbols:
a) NFA
b) DFA
c) Pushdown automata
d) All of the mentioned
Answer :- For Answer
9. The____________ of a set of states, P, of an NFA is defined as the set of states reachable from
any state in P following s-transitions
a) s-closure
b) s-park
c) Q in the tuple
d) None of the mentioned
10. Between NFA and DFA which one is powerful
a) NFA
b) DFA
c) Equally powerful
d) Cannot be said definitely
11. Subset Construction method refers to
a) Conversion of NFA to DFA
b) DFA minimization
c) Eliminating null references
d) &-NFA to NFA
12. Which of the following do we use to form an NFA from a regular expression
a) Subset construction method
b) Powerful set construction method
c) Thompson construction method
d) Scott construction method
13. 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
Compiler Design Week 2 Nptel Assignment Answers
For answers to others Nptel courses, please refer to this link: NPTEL Assignment