Tải bản đầy đủ (.pdf) (1 trang)

Tutorial 1

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (29.69 KB, 1 trang )

COMPILER CONSTRUCTION
Week 2 Tutorial Questions
Regular Expressions, NFA and DFA
1. Let ∑ = {a,b}. Write regular expressions for the languages over ∑ that contain:
a. All strings.
b. The empty string.
c. The string abb.
d. The strings ba and aba.
e. All strings beginning with ab.
f. All strings beginning with a a and ending with a b.
g. All strings that contain exactly two a’s.
h. All strings in which every a is followed by a b.
2. Construct nondeterministic finite automata (NFA) from the following regular
expressions:
a. (a|b)(a|b)
b. a(a|b)+
c. (ab|b)*a
d. abb(a|b)?a
Note: You may use Thompson’s construction algorithm.
3. Construct deterministic finite automata (DFA) from the NFA’s constructed in
question 2.
4. Minimise the following DFA:
a

B
a

a
a

A



b

a

C
b

b
D

E
b

b

5. Write a phrase using wildcards
to find the following words in a document written in MSWord:
a. Any number.
b. “get” and “got”.
c. Any word that starts with a ‘s’ and ends with ‘t’. E.g. “sit”, “shoot”,…
d. Any word whose beginning is “re”. E.g. “repeat”, “recharge” but not “trend”



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×