Nondeterministic finite automaton understanding problem

85 Views Asked by At

It is probably a silly question but I have problem understanding it. Let's say I have to design a nondeterministic finite automaton that accepts the language consisting of words containing a string of three binary zeros or three ones. The example of that looks like that (q0 is beginning state; q5,q6 are ending states) enter image description here

But I don't understand if in nondeterministic solution you have a choice to which state you want to go why it can't be just only 2 states ? in here for example for input 1011100 you would go:

1 stay in q0

0 stay in q0

1 stay in q0

1 stay in q0

1 go to q1

0 stay in q1

0 stay in q1

(q0 is beginning state, q1 is ending state) enter image description here

1

There are 1 best solutions below

2
On BEST ANSWER

An NFA accepts a word $w$ if $w$ governs at least one path from the initial state to an acceptor state. Thus, your second automaton accepts every non-empty word in $\{0,1\}^*$: every such word can reach $q_1$ (though of course it needn’t).