简体   繁体   中英

construct an FA (theory of automata)

You are required to construct a finite automaton for the language of all those strings whose length is odd , but contain an even number of b's defined over the alphabet {a,b}.

I have done this

((a+b)(a+b))*bb+bb*((a+b)(a+b)) 

but I know this is wrong, so what is the answer to this question?

You say you are looking for an automaton, but your (wrong) answer is a regular expression. I will provide an automaton. It uses two counters mod 2; one for the length, one for the number of b. So the states are:

q[0,0], q[0,1], q[1,0], q[1,1]

where eg q[0,1] means that the total length is even (first zero) while the number of b is odd (the one). So the final state is q[1,0] while q[0,0] is initial.

The transitions are rather obvious, doing the necessary changes for the counters:

q[0,0] reads a  ->  q[1,0] 
q[0,0] reads b  ->  q[1,1]
q[0,1] reads a  ->  q[1,1]  
q[0,1] reads b  ->  q[1,0]
q[1,0] reads a  ->  q[0,0] 
q[1,0] reads b  ->  q[0,1]
q[1,1] reads a  ->  q[0,1]  
q[1,1] reads b  ->  q[0,0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM