Daffodil International University
Department of Computer Science and Engineering
Faculty of Science & Information Technology
Midterm Examination, Summer 2020 @ DIU Blended Learning Center Course Code: CSE331 (Evening), Course Title: Compiler Design
Level: 2 Term: 1 ,3 Section: PC-A(EVE) Instructor: SZ Modality: Open Book Exam Date: Sunday 12 July, 2020 Time: 05:00pm-09:00pm
Four hours (4:00) to support online open/case study based assessment Marks: 25 Directions:
Students need to go through the CASE STUDY shown in this exam paper.
Analyze and answer specific section based on your own thinking and work.
Do not share as this will be treated as plagiarism by Blended Learning Center.
1. In physics, equations of motions are equations that describe the behavior of a physical system in terms of its motion as a function of time. One of the equation of motion can be described by the following equation: s = u * t + (1/2) * a * t * t
Consider that you have written a code containing the equation given above. Now explain how the compiler will work on that equation in the following phases: 6
a. Lexical Analyzer
b. Intermediate Code Generator
c. Code Optimizer
d. Final Code Generator
2. Consider the following Finite Automata:
Figure: 1
a. Give the formal definition of the Finite Automata of Figure 1. 2 b. Is the Finite Automata of Figure 1 a NFA? Give reasons behind your decision. If it is a 7
NFA then write down the subset construction table for converting it to DFA.
3.
a. Consider the following statements and explain if the statements are example of CFG. Give reasons behind your decision. 2 ABCD
BAB D Dc cAc
b. Consider the following CFG: 4 XXYX|0|1|Z
Y ZX|0|1 ZƐ|0|1
Now derive the string “01010101010100” using LMD and RMD from the grammar. Is the grammar ambiguous?
4. Write down the regular expressions for the following languages: 1+2+1=4 a. All strings of a, b, and c, that starts with at least one a or b which is followed by the
appearance of exactly two c’s and then end by the appearance of even number of b’s
b. Assume that Σ={L,N,C}, where L is for English letters (A-Z|a-z), N is for numbers (0-9) and C is for characters excluding English Letters and numbers. Now write down the regular
expression of an email address.
c. All strings of a’s and b’s that has at least six consecutive a’s.