DFA Examples
DFA Examples
1
Text and Reference
Material
2
FA - Examples
• All words that must have ‘aa’ or ‘bb’ in it
• All words that must have ‘aaa’ or ‘bbb’ in it
• All words that have ‘b’ at 3rd place
• All words that accept/have ‘baa’ in it
• All words that only accept/have ‘baa’
• All words that accept/have ’baa’ or ‘ab’ in it
• All words that must have ‘aa’ in it
• All words that only accept/have ‘aa’
• All words start with ‘a’ and ends with ‘b’ and vice versa
• Language that must accepts b*a+ = b*a a*
3
Example
• Consider the Language L of strings , defined over Σ = {a, b},
have ‘aa’ or ‘bb’ in it.
• RE: (a+b)* (aa+bb) (a+b)*.
• FA :
a,b
a
+
a
– a b
b
b
4
Example
• Consider the language L of strings, defined over Σ={0, 1}, having
double 0’s or double 1’s,
• RE: (0+1)* (00 + 11) (0+1)*
• FA
0
0
0,1
- 0 1 +
1
1
5
Example
• Consider the Language L of strings , defined over Σ = {a, b},
containing double a.
• RE: (a+b)* (aa) (a+b)*.
• FA :
b a,b
a
a +
-
6
Example
• Consider the language L of strings, defined over Σ={a,
b}, having triple a’s or triple b’s.
• RE : (a+b)* (aaa + bbb) (a+b)*
• FA
a
a
a b a,b
–– a b +
b a
b
b
7
Example
• Build an FA for the language L of strings, defined over
Σ={a, b}, having b at 3rd place.
• RE (a+b) (a+b) b (a+b)*
• FA
a,b
a,b a,b b
- +
a,b
a
a,b
8
Example
• Build an FA for the language L of strings, defined over
Σ={a, b}, that accept/have baa in it.
• FA
b
a
b a, b
a,b
9
Example
• All words that only accept/have ‘aa’
10
Example
• Build an FA for the language L of strings, defined over
Σ={a, b}, that only accepts baa or ab.
• FA
a,b
b
a,b
b
- +
a
b
a,b
11
Task
• Build an FA accepting the Language L of Strings, defined over Σ = {a, b},
beginning with and ending in same letters.
• RE: (a+b)+a(a + b)*a + b(a + b)*b
• FA
a b a
b
+ +
a b
– b a b
b a
+ +
a
12
Example
• Consider the Language L of Strings , defined over Σ = {a,
b}, beginning with and ending in different letters.
• RE: a (a + b)* b + b (a + b)* a
• FA :
a b b
+
a a
–
b a a
b
+
b
13
Example
• Build an FA for the language L of strings, defined over
Σ={a, b}, where b*a+ = b*a a*.
• FA
b a
a
– +
a,b
14
Example
• Build an FA for the language L of strings, defined over
Σ={a, b}, of odd length.
• RE (a+b)((a+b)(a+b))* or ((a+b)(a+b))*(a+b)
• This language may be accepted by the following FA
a,b
– +
a,b
15
Example
• Consider the Language L , defined over Σ = {a, b} of all strings
including Λ,
a,b
a,b
+
• RE: (a + b)*
a,b
16
Example
• Consider the Language L , defined over Σ = {a, b} of all
non empty strings.
• RE: (a + b)+
a,b
a,b
– +
17
Example
• Consider the EVEN-EVEN language, defined over Σ={a, b}.
• RE: (aa+bb+(ab+ba)(aa+bb)*(ab+ba))*
FA
b
b
a a a a
b
18
FA Example
• Consider the language L = {Λ, b, ab, bb}, defined over
• Σ ={a, b}, expressed by a,b
• RE:
• Λ + b + ab + bb OR Λ + b (Λ + a + b)
• FA a
a,b
• Dead state/Black Holes:
a b
+
• the moment one enters these
states there is no way to leave it.
b
+ b +
a,b
a
19
a,b
FA - Examples
• All words that have four or more letters
• All words that have fewer than four letters
• All words that exactly has four letters
• All words of length even but not divisible by 6
• Even length
• Odd length
20
Equivalent FAs
• It is to be noted that two FAs are said to
be equivalent,
if they accept the same language, as shown in
the following FAs.
21