0% found this document useful (0 votes)
229 views

Formal Languages and Automata: Lab 4. Exercises

This document contains 10 exercises related to formal languages and automata. Exercise 1 asks about languages recognized by two nondeterministic finite automata (NFAs). Exercises 2-4 involve designing NFAs for specific languages. Exercises 5-7 involve drawing NFAs that recognize languages related to string endings. Exercises 8 modifies a Java program. Exercises 9 and 10 involve converting NFAs to equivalent automata without lambda transitions or to deterministic finite automata.

Uploaded by

Yuri Kim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views

Formal Languages and Automata: Lab 4. Exercises

This document contains 10 exercises related to formal languages and automata. Exercise 1 asks about languages recognized by two nondeterministic finite automata (NFAs). Exercises 2-4 involve designing NFAs for specific languages. Exercises 5-7 involve drawing NFAs that recognize languages related to string endings. Exercises 8 modifies a Java program. Exercises 9 and 10 involve converting NFAs to equivalent automata without lambda transitions or to deterministic finite automata.

Uploaded by

Yuri Kim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Formal Languages and Automata 

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.

You might also like