Regular Expression to Finite Automata Examples

For Complete YouTube Video: Click Here

In this class, we discuss Regular Expression to Finite Automata Examples.

The reader should have prior knowledge of regular expression to finite automata for operators. Click Here.

Example 1:

Given regular expression r= 0* + 11

In our previous classes, we discussed how to write finite automata for 0* and 11.

We write them and join to get the final regular expression.

Take r1 = 0*

the below diagram shows the finite automata for 0*.

Regular Expression to Finite Automata Examples 1.1
r1

Take r2 = 11.

The below diagram shows the finite automata for 11.

Regular Expression to Finite Automata Examples 1.2
r2

The final regular expression is given as r = r1 + r2.

The union operator applied between r1 and r2.

The below diagram shows the final finite automata for regular expression r.

Regular Expression to Finite Automata Examples 2.1
r

Example 2:

The given regular expression r= (10*)*.

Take r1 = 1

The below diagram shows the finite automata for r1.

Regular Expression to Finite Automata Examples 3.1
r1

Take r2 = 0*.

The below diagram shows the finite automata for r2.

Regular Expression to Finite Automata Examples 3.2
r2

The final regular expression is r = (r1.r2)*

We need to concatenate r1 and r2; then, we apply a closure.

Point to understand: How we apply closure for r1.r2

The below diagram shows the finite automata for (10*)*

Regular Expression to Finite Automata Examples 3.3
r

To repeat the expression 10*, we applied epsilon moves from state q6 to q1.

And to accept the epsilon transition, we apply epsilon moves from state q0 to q7.

The state q7 is the final state.

Similarly, We can write finite automata for any regular expression.