开发者

Is this DFA correct?

I'm supposed to construct a DFA which accepts

{ w | w is a word except 'aa' and 'aaa' }

Is this the correct solution? The thick line state is supposed to be the end state.

EDIT

Sry, somehow mixed two different exercises. 开发者_JS百科Corrected.

EDIT 2

Here's the corrected solution(?)!


I will leave the answer below intact since it's useful in context.

With your update to the question, and your further update with the proposed solution, it would appear to me that it would be valid. Well done!

========= Old post for historical purposes ===========

Important note: aa is a substring of aaa. So by excluding aa, you automatically exclude aaa and aaaa and aaaaa. This means you can only ever have 1 a in a row.

So whenever you add an a, you need to go to an accept state. Whenever you add an a after that, you need to go to a non accept state that loops forever no matter what.

Below is what I came up with. I do not recommend just... putting it down. Think about this. These problems are very important in training how you think!!! Don't spoil yourself!

S denotes start state + on corner denotes accept state X on corner denotes not accept state

 B  +-+  A   +-+  A   X-X  A | B
+---|S| ---> |1| ---> |2| ------+
|   +-+      +-+      X-X       |
+___^ ^___B___|       ^________+

"" - ends on start - okay 
"B" - ends on start - okay 
"A" - ends on 1 - okay 
"AA" - ends on 2 - not accepted 
"BAA" - Stats on S, goes to S, goes to 1, goes to 2 - not accepted.

A - moves you down the line toward failure. B - resets you. two As in a row and you fail :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜