You are on page 1of 2

Daffodil International University

Department of Computer Science and Engineering


Faculty of Science & Information Technology
Midterm Examination, Spring 2021 @ DIU Blended Learning Center
Course Code: CSE 331 (Day), Course Title: Compiler Design
Level: 3 Term: 3 Section: All
Modality: Open Book Exam
Date: Sunday 7 March, 2021 Time: 09:00 AM - 11:30 AM Marks: 25
Life will give you many options, but today you have to “Answer all the questions”
Q1. Construct an equation using the following information. [5]
Multiply the last two digit of your student ID with X, divide 15 by Y, then add the result
of multiplication and division. Finally, subtract 7 from the summation and assign it into
“Total_Value”. Consider, X, Y as float-value.
Construct the step-by-step phase of a compiler with the constructed equation.
Q2. (a) Consider the following CFG-1 and answer the following question. [6]

P  ABCD
A  aA | cC | oD | iC
B  ov | ovC
C  id | id-D | ɛ
D0|1|2|3|4|5|6|7|8|9
CFG-1
Find out if the above mentioned CFG is ambiguous or not, and give proper
justification. You may use “covid-19” as input string to test the ambiguousness.
(b) Consider the following CFG-2 and answer the following questions. [4]

X  QRP
Q  vR | vP
R  acc | accPP | at | atPP
Pi|n|o|ɛ
CFG-2
Use LMD and RMD to produce “vaccination” from the above CFG-2.

Q3. (a) Draw NFA from the following regular expressions. [3]
+ +
i. 0 (0 U 1) 1
ii. A(B+D)C | PQ*R
(b) Convert the following NFA in Fig.1 into a DFA using subset construction method. [5]

Fig. 1. NFA for Q2(b)


(c) For each of the following strings, draw the path and determine whether it is [2]
recognized by the output DFA of Q2(b) or not.
i. aabbaaaa
ii. bbaabbab
iii. aabba
iv. bab

“The bad news is time flies. The good news is you’re the pilot” - Michael Altshuler
Best of luck 

You might also like