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
Asked
Active
Viewed 147 times
0
-
Welcome to Stack Overflow. Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then check the [help/on-topic] to see which questions are on-topic on this site. You might want to delete this question and ask it on https://cs.stackexchange.com/ instead, but check the help pages there first. – Progman Feb 14 '22 at 23:36
1 Answers
1
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+):

Oliver Mason
- 2,240
- 2
- 15
- 23