Celeb Glow
general | April 16, 2026

How do you draw a DFA from a regular expression?

$\begingroup$

I want to draw a DFA from the below language:

The set of strings in $\{a, b\}$ where every $a$ is immediately followed by $b$

I can write the regular expression for this language as so:

$$((b^*)(ab)(b^*))^*$$

How do I draw the DFA for this expression?

$\endgroup$ 1

2 Answers

$\begingroup$

I hope it can help you

Language consist of :

  • $\epsilon$
  • strings of just b's
  • and strings such that every a is immediately followed by b$$L=\{\epsilon,b,bb,bbb,...,ab,abb,....,bab,bbababb,.... \}$$ Regular expression: $(b^*\,ab\, b^*)^*+b^*$

DFA that accepts L :

enter image description here

$\endgroup$ 2 $\begingroup$

You can do it on-line using easily. For your particular example, it gives

enter image description here

You can find a more precise algorithm in the chapter 2 of Modern Compiler Implementation in C, which includes this figure:

enter image description here

How you convert your obtained NFA into a DFA is then fairly standard.

$\endgroup$ 1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy