Design a DFA that accepts at most 3 a"s

Construct deterministic finite automata that accepts at most 3 a’s over an alphabet ∑={a,b}.

At most 3 a’s means,

The string contains 0 to max 3 a’s and any number of b’s.

L= {Є,a,aa,aaa,ab,abb,bab,bbabaa, bbabaabbb,…..}

Construct DFA

Let’s construct DFA step by step −

Step 1

Valid inputs − aaa, a, aa,ε .

Step 2

Valid inputs − b, ba, baa, baaa, bb, bba, bbba,…

Step 3

Valid input − bab, abba, abbbaa, babba,…

Step 4

Valid inputs − babab, aabb, aaba, bbbaaba, …

Step 5

Valid inputs − aaabbb, aaabab, baaaba, …

Step 6

InValid inputs − aaaa, aaabab, baaaba,