MCS-212 · Block 2 Unit 2

Automata and Languages

Section 8 of 8

Block 2 · Unit 2Automata and Languages13 min · Section 8 of 8

2.8Nondeterministic finite automata

Covers IGNOU MCS-212 §2.5, Example 20, Ex.13, Ex.14

Some languages are much easier to describe with a machine that is allowed to “guess”. For “strings ending in 01” you would like to say: stay put, and when you see the 0 that starts the final 01, jump ahead. A nondeterministic finite automaton (NFA) allows exactly this. Surprisingly, it is no more powerful than a DFA — but it is often much simpler to design.

Example: strings ending in 01

The NFA has states q0q_0 (start), q1q_1, q2q_2 (final):

State01
→ q0q_0{q0,q1}\{q_0, q_1\}{q0}\{q_0\}
q1q_1∅\emptyset{q2}\{q_2\}
q2q_2 (final)∅\emptyset∅\emptyset

q0q_0 loops on everything; on a 0 it may also “guess” that the final 0101 starts here.

From NFA to DFA: the subset construction

Idea (subset construction): each state of MM is a set of states of NN — exactly the “coins” of the intuition. The start state is {q0}\{q_0\}; from a set SS on symbol aa, go to the union of δ(q,a)\delta(q, a) for q∈Sq \in S; a set is final if it contains a final state of NN. Only the sets actually reached need to be built. An NFA with nn states can need up to 2n2^n DFA states, but usually far fewer.

Key takeaways

  • NFA: δ(q,a)\delta(q, a) is a set of states (possibly empty).
  • Accept if at least one path ends in a final state; track the set of reachable states.
  • Subset construction: DFA states are sets of NFA states.
  • NFAs and DFAs recognise the same languages — the regular languages.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

In an NFA, what is the type of the transition function?

Show answer

Answer: B. Q×Σ→P(Q)Q \times \Sigma \to P(Q)

It returns a set of states (possibly empty). Option 1 is the DFA transition function.

Question 2 · multiple choice

For the “ends in 01” NFA, what is the set of states after reading 1010?

Show answer

Answer: C. {q0,q1}\{q_0, q_1\}

{q0}→1{q0}→0{q0,q1}\{q_0\} \xrightarrow{1} \{q_0\} \xrightarrow{0} \{q_0, q_1\}. Option 4 is wrong because q0q_0 always has moves.

Question 3 · multiple choice

An NFA has some paths for ww that get stuck and one path that ends in a final state. Is ww accepted?

Show answer

Answer: A. Yes

One successful path is enough. Options 2 and 3 describe a much stricter rule than the definition.

Question 4 · multiple choice

Using the subset construction, at most how many DFA states can come from an NFA with 4 states?

Show answer

Answer: D. 16

Each DFA state is a subset of the 4 NFA states, and there are 24=162^4 = 16 subsets. Usually fewer are reachable.

Question 5 · multiple choice

Which string is accepted by the NFA of Ex.13 (“ends in 01”)?

Show answer

Answer: C. 011101011101

011101011101 ends in 01. The others end in 10, 10 and 11.

Question 6 · short answer

Give an NFA over {a,b}\{a, b\} that accepts the strings starting with abab (Ex.14), and check abbaabba and baba.

Show worked answer

States q0q_0 (start), q1q_1, q2q_2 (final). δ(q0,a)={q1}\delta(q_0, a) = \{q_1\}, δ(q1,b)={q2}\delta(q_1, b) = \{q_2\}, δ(q2,a)=δ(q2,b)={q2}\delta(q_2, a) = \delta(q_2, b) = \{q_2\}; all other transitions are ∅\emptyset. abbaabba: {q0}→{q1}→{q2}→{q2}→{q2}\{q_0\} \to \{q_1\} \to \{q_2\} \to \{q_2\} \to \{q_2\}, accepted. baba: {q0}→b∅\{q_0\} \xrightarrow{b} \emptyset, stuck, rejected.

↑ ↓ move↵ openTab switch type