how to draw this DFA?

472 Views Asked by At

{w belongs to all string patterns as a^i b^j a^k | i+j=even and j+k =odd}

draw a DFA and find its regular language.

please note here, i have put comma in between the format of aba string just for easy understanding for all viewers.

what i have done so far is , the 2 possible condition should be 1) i=even, j=even, k=odd 2) or i=odd, j=odd, k=even

Can you tell me if b, ba, bba, bbbbbaba,aaaba are accepted or not??

1

There are 1 best solutions below

6
On

OK, the regular language expression should be: (a(aa)*b(bb)*(aa)*)U((aa)*(bb)*a(aa)*) meaning, as you already stated: either the first block of a's and b's should each have an odd number, and the second block of a's should have an even number,
or the first block of a's and the b's should have an even number, and the second block of a's should have an odd number (a handy trick for getting k modulo n of some letter is the expression $a^k(a^n)^*$, here for an odd number of a's for example, we use the a(aa)* expression).

The automaton should look like this (accepting states marked with double circle):
automaton for the language above.

As to your question, it is easy to see (following the automaton) that bba is accepted, and the rest rejected.