Compiler-As-1

2024-10-07 1
手机查看

Question 1

Let Design a DFA for each following language (6 marks for each)

Current State

1-a-DFA

Current State

1-b-DFA

Current State

1-c-DFA

Question 2

Design a regular expression for each language in Q1. (6 marks for each)

a.
b.
c.

Question 3

Let Convert the regular expression  to an NFA. (10 marks)

3-NFA

Question 4

Given the following NFA

4-NFA

a. Convert the NFA to the equivalent DFA. (20 marks)

First iteration

Second iteration

Third iteration

Fourth iteration

Fifth iteration

Sixth iteration

Seventh iteration

4-a-DFA

b. Minimize the DFA in part a). (20 marks)

Initially,

and act in the same way, Thus and should be in the same group.

and act in the same way, Thus and should be in the same group.

Finally, the minimized DFA is:




4-b-DFA

Question 5

Consider a new alphabet

a. Design a DFA with a trap state which recognizes the keywords if or else. (The DFA does not accept any other string.) (10 marks)

5-a-DFA

b. Represent the DFA using a transition table. (4 marks)