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更新日 2026/9/24
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.