FA that accepts only those words that have an even number of substrings cdc?

5.5k Views Asked by At

I take this question as it could accept cdccdc,cdccdccdccdc,dddcdccdc,etc. I feel that I coveed all the even loops of cdccdc but I am stuck trying to figure out how to add in c* and d* in the mix of strings so that it is like ddddcccdccdcdddcc

this is what I have so far enter image description here

thanks

Update

Yes, I have to have it accept even lengthed cdc so "cdccdccdccdc" is acceptable also would be "ddcdccdcddddcccdccdcdd"

1

There are 1 best solutions below

3
On BEST ANSWER

Try the following:

enter image description here

The formatting isn't perfect. But the idea is to loop until you find a $c$, then try to find a $cdc$. If you don't find the correct next character, go back and start over. Once you find a $cdc$, move to the other (left) half of the diagram and do it all again. Once you've found the second $cdc$, accept. The rest of the string is irrelevant. If you run out of characters before accept, you fail.