Design finite automata from regular expressions
Last Updated :
05 Jul, 2021
Prerequisite - Finite automata, Regular expressions, grammar, and language.
In this article, we will see some popular regular expressions and how we can convert them to finite automata (NFA and DFA). Let's discuss it one by one.
Overview :
Let a and b are input symbols and r is the regular expression. Now we have to design NFA as well as DFA for each regular expression.
Design finite automata from the regular expression :
Here, we will discuss the Design of finite automata from regular expression as follows.
Case-1 :
When r = Φ, then FA will be as follows.

Case-2 :
When r = ε, then FA will be as follows.

Case-3 :
When r = a, then FA will be as follows.

Case-4 :
When r = a+b , then FA will be as follows.

Case-5 :
When r = r = a* , then FA will be as follows.

Case-6 :
When r = a* + b*, then FA will be as follows.

Case-7 :
When r = (ab)*, then FA will be as follows.

Case-8 :
When r = (ab)*b, then FA will be as follows.

Case-9 :
When r = (ab)*a, then FA will be as follows.

Case-10 :
When r = a*b*, then FA will be as follows.

Case-11 :
When r = (a+b)*, then FA will be as follows.

Unary Design :
Let a is the input symbol and r is the regular expression. For each regular expression, we will design finite automata.
Case-1 : r = a*

Case-2 : r = (aa)*

Case-3 : r = (aa)*a

Case-4 : r = aaaa*

Case-5 : r= (aa + aaa)*

Case-6 : r=( aaa+aaaaa)*

Case-7 : r=(aa + aaaaaa)*
It is a multiple of 1 term i.e. aa, so it can be reduced to r=(aa)*.

L= {an | n = 7x+12, x € Z, x >=0 }

General Methods :
Here, we will discuss some general methods as follows.
Method-1 :
L = { aK1n+K2 ; n>=0 }
If K1>K2, No. of states = K1
If K1<K2, No. of states = K2 +1
If K1=K2, No. of states = K1 +1 = k2 +1
Method-2 :
L = { aKn ; n>0 , K is a fixed integer }
= { aKn ; n>=1. K is an integer}
No. of states = K +1
Method-3 :
L = { aKn ; n>=0 , K is a fixed integer }
Here, residue i.e. K2=0, K1>K2. Therefore, No. of states = K
Similar Reads
Designing Finite Automata from Regular Expression (Set 7) Prerequisite: Finite automata, Regular expressions, grammar and language, Designing finite automata from Regular expression (Set 6) In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Regular language, L1 = b*aa(a+b)*+b*ab*aa(
3 min read
Designing Finite Automata from Regular Expression (Set 2) Prerequisite: Finite automata, Regular expressions, grammar and language. Designing finite automata from Regular expression In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Φ (Phi). The language of the given RE is L1 =
3 min read
Designing Finite Automata from Regular Expression (Set 6) Prerequisite: Finite automata, Regular expressions, grammar and language, Designing finite automata from Regular expression (Set 5) In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Regular language, L1 = a(a+b)* The languag
3 min read
Designing Finite Automata from Regular Expression (Set 4) Prerequisite: Finite automata, Regular expressions, grammar and language, Designing finite automata from Regular expression (Set 3) In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Regular language, L1 = (a+b)(a+b) The lang
3 min read
Designing Finite Automata from Regular Expression (Set 1) A regular expression is a simple way to describe patterns in text, like âany number of a'sâ (a*) or âeither a or bâ (a|b). A finite automaton is a basic machine that reads a string one letter at a time and decides if it matches a given pattern. Converting a regular expression to a finite automaton m
4 min read