NPTEL Compiler Design Week 2 Assignment Answers 2024

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

NPTEL Compiler Design Week 2 Assignment Answers 2024

1. Consider the following C-program segment.

NPTEL Compiler Design Week 2 Assignment Answers 2024

How many lexical errors are there in the segment?

(A) No lexical error
(B) One error
(C) Two errors
(D) Three errors

Answer :-  For Answer Click Here

2. Which of the following machine model is necessary and sufficient for lexical analysis of modern computer languages?

(A) Finite automaton
(B) Pushdown automaton
(C) Turing machine
(D) None of the other options

Answer :-  For Answer Click Here

3. Consider the following regular expressions:

NPTEL Compiler Design Week 2 Assignment Answers 2024


Choose the correct statement from the options given below. Here, L(r) and L(s) represent the languages generated by r and s respectively.

(A) L(r) is a subset of L(s)
(B) L(s) is a subset of L(r)
(C) L(r) = L(s)
(D) None of the other options

Answer :-  For Answer Click Here

4. Which of the following strings is a member of the set represented by the regular expression a(a|b)*a?

(A) aabab
(B) aababa
(C) aaab
(D) bababa

Answer :- 

5. Properties followed by the strings conforming to the regular expression (0|1)*0(0|1)(0|1)(0|1) is/are:

(A) Length at least 4
(B) Fourth character from end is a 0
(C) Ends with 0 or 1
(D) All of the other options

Answer :- 

6. Which of the following is the regular expression to represent all binary strings except empty string?

(A) (0|1)(0|1)*
(B) (0|1)*
(C) 01*
(D) None of the above

Answer :-  For Answer Click Here

7. What is the language of the grammar G: A → aB, B → aC, C → aA, C→ a

(A) a3i, i>0
(B) a+
(C) a2i, i>0
(D) None of the other options

Answer :- 

8. Which of the following is the regular expression to represent all binary strings having at least 3 characters, and the third character is 0?

(A) 0(0|1)0(0|1)*
(B) 1(0|1)0(0|1)*
(C) (0|1)(0|1)0(0|1)*
(D) (0|1)(0|1)0(0|1)

Answer :- 

9. How many bit strings of length exactly five are matched by the regular expression 0(0|1)*1?

(A) 8
(B) 10
(C) 12
(D) 14

Answer :- 

10. How many bit strings of length at most four are matched by the regular expression 0(0|1)*1?

(A) 5
(B) 6
(C) 7
(D) 8

Answer :-  For Answer Click Here

11. What is the language of the following finite state machine?

NPTEL Compiler Design Week 2 Assignment Answers 2024


(A) All strings over the alphabet {a,b} with an even number of a’s and an odd number of b’s
(B) All strings over the alphabet {a,b} with an even number of a’s and an even number of b’s
(C) All strings over the alphabet {a,b} with an odd number of a’s and an odd number of b’s
(D) All strings over the alphabet {a,b} with an odd number of a’s and an even number of b’s

Answer :- 

12. What is the language of the following finite state machine?

NPTEL Compiler Design Week 2 Assignment Answers 2024


(A) All strings over the alphabet {a,b} with an even number of a’s and an odd number of b’s
(B) All strings over the alphabet {a,b} with an even number of a’s and an even number of b’s
(C) All strings over the alphabet {a,b} with an odd number of a’s and an odd number of b’s
(D) All strings over the alphabet {a,b} with an odd number of a’s and an even number of b’s

Answer :- For Answer Click Here