简体   繁体   中英

Draw an FSA that recognizes: (A∗ | AB+). (The bar outscopes the other operators, so its equal to: (A∗) | (AB+).) Use as few states possible

I've attached what I have. My problem is that I don't know if its correct and if I've even used the fewest states possible to answer this question. Really appreciate any help on what I currently did wrong this is what i have currently

I would start by creating two FSAs, one for each of the branches.

For A* you only need one state.

For AB+ you need three states.

Then you merge the two. Assuming it does not have to be deterministic, the total FSA ends up with three states as well, two of which are final states.

As you tagged your question dfa — a deterministic FSA would need 4 states in total:

Start state: 1; Final States: 1,2,3,4

Transitions:

1 - a -> 2
2 - a -> 4
2 - b -> 3
3 - b -> 3
4 - a -> 4

That is a DFA that recognises (a*|ab+):

使用 graphviz 绘制的 FSM

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