Formal Languages and Automata: Lab 4. Exercises
Formal Languages and Automata: Lab 4. Exercises
Formal Languages and Automata: Lab 4. Exercises
Lab 4. Exercises
Exercise 1
1. What is the language recognized by N1 and by N2 ?
2. Show a sequence of states in N2 that makes the string 1011 be accepted.
N1:
N2:
Exercise 2
Find a nondeterministic finite-state automaton that recognizes each of the following sets.
a) {0}
b) {1, 00}
c) {1n| n = 2, 3, 4, …}
and has fewer states, if possible, than the deterministic automaton you found in the previous
exercise.
Exercise 3
Design λ–NFA’s for the followings languages:
a) The set of strings consisting of zero or more a’s followed by zero or more b’s, followed by
zero or more c’s.
b) The set of all strings that consist of either 01 repeated one or more times or 010 repeated
one or more times.
Solution
a)
b)
Exercise 4
Draw an NFA that matches all strings that contain either a multiple of 3 1's or a multiple of 5 1's.
Hint: Use 3 + 5 + 1 = 9 states and one lambda transition.
Exercise 5
Draw an NFA that recognize the language of all strings that end in aaab.
Exercise 6
Draw an NFA that recognize the language of all strings whose 4th to the last character is a.
Exercise 7
Draw an NFA that recognize the language of all strings whose 5th to the last character is a.
Exercise 8
Modify CommentStripper.java to:
1. Remove entirely blank lines.
2. Properly handle characters within quote strings.
Exercise 9
Given the following NFAs with λ-transitions. Write equivalent NFAs that has no λ -transitions.
1.
2.
3.
Exercise 10
Given the following NFA. Write equivalent DFA with minimum states.