ChatDiagram
automata theory · string matching

NFA for binary strings containing 101

This NFA accepts binary strings that contain 101 as a substring. State q0 reads through any prefix and loops on both symbols. On a 1, it can also branch to q1 and treat that symbol as the start of a possible match. The path q1 to q2 to q3 then requires 0 followed by 1. Once q3 is reached, it loops on either symbol because the required substring has already been found. Nondeterminism matters when possible matches overlap: the q0 loop can continue scanning while another path tests a particular 1. This same pattern adapts naturally to searching for another fixed word or protocol marker.

סוג תרשים מצביםתקן OMG UML 2.5.1 §14 + Harel (1987) statechartמנוע schematex-stateעודכן 24.9.2026
NFA for strings containing 101
Drawing preview
הבקשה

“Draw an NFA over 0 and 1 that accepts strings containing 101: q0 loops on both symbols and can start a match on 1, followed by 0 to q2 and 1 to accepting q3, which loops on both symbols.”

ואז נסוChange the sought substring from 101 to 110.Remove the loops from q3 so the machine accepts only strings ending in 101.
מה מופיע בתרשים הזה

פענחו את ההחלטות שמאחוריו.

01Scanning loop

q0 can skip an arbitrary prefix.

02Nondeterministic start

a 1 can be ignored or treated as the first symbol of 101.

03Accepting loop

q3 permits any suffix after a completed match.

Use this structure to recognize whether a short token occurs anywhere in a stream.

עיון בכל תבניות ה־תרשים מצבים ←

שאלות נפוצות

שאלות נפוצות

Why is q3 an accepting state with loops?

After finding 101, any remaining binary suffix still belongs to the language.

Can overlapping matches be handled?

Yes. Nondeterministic paths let the automaton test different starting positions at once.

Does 1001 get accepted?

No. It does not contain 101 as consecutive symbols.