skip to content

questions

25

A deterministic finite acceptor reads a digit string one symbol at a time — what decides that it accepts?

level: juniorimportance: must knowfreq 66%

answer

  1. one machine, one summary
  2. no buffer, no second look
  3. the run is a walk over states
  4. verdict only when input runs out
  5. final state against the accepting set

basics

~20 s

One fact decides it: the state the machine is left in after the final symbol. If that state is in the accepting set, the string is accepted. Passing through an accepting state earlier in the run means nothing.

solid answer

~40 s

A deterministic finite acceptor is five things: a finite set of states, an input alphabet, a transition function that gives exactly one next state for every state-and-symbol pair, a start state, and a set of accepting states. A run begins in the start state, and each symbol replaces the current state with the one the transition function names. There is no lookahead, no backtracking and no memory besides the state itself. When the input is exhausted, the machine accepts if the state it is sitting in belongs to the accepting set, and rejects otherwise. So the verdict is pronounced exactly once, at the end of the input — visiting an accepting state halfway through is not acceptance.

go deeper

for a junior

Recall the run: start state, one transition per symbol, and a verdict taken from the state you end in. Be able to trace a four-symbol input on a two-state machine without losing your place.

for a middle

Explain why the transition rule being single-valued makes the run unique, and why the state after the last symbol is a complete summary of everything read.

for a senior

Show that you use the model to argue about a real streaming validator: fixed memory, one pass, no buffer, and a verdict that cannot be taken before the input ends unless the state is already absorbing.

for a principal

Frame it as a cost decision: a recogniser of this shape buys bounded, predictable memory and latency on a device that cannot buffer, and the price is that everything it must remember has to be named as a state up front.

## The five parts of the machine A **deterministic finite acceptor** is a recogniser whose entire memory is one state drawn from a finite set. It is defined by five things, and every claim about it comes back to them: - **States** — a finite set `Q`. The current state is the machine's whole memory: no tape, no counter, no buffer beside it. - **Alphabet** — a finite set of symbols it may read, for instance the ten decimal digits a scanner emits. - **Transition function** — `delta(state, symbol)`, which names **exactly one** next state for every state-and-symbol pair. That single-valuedness is what the word *deterministic* means. - **Start state** — one designated state. Every run begins there, whatever the input is. - **Accepting states** — a subset of the states. Being in that subset is the only thing in the whole model that means "yes". ## What a run is 1. Put the machine in the start state. 2. Read the input left to right. In state `q`, reading symbol `s`, replace the state with `delta(q, s)` and move on. Nothing else happens: no output, no counter, no note kept about earlier symbols. 3. When the input is exhausted, **accept if the state you are left in is an accepting one, and reject otherwise**. Three consequences follow directly: - **No lookahead and no backtracking.** The machine never inspects a symbol it has not reached, and never returns to one it has passed. - **One run per string.** Because the transition rule is a function, the same input always walks the same path and always gets the same verdict. - **The verdict is pronounced once, at the end.** Entering an accepting state mid-run is not acceptance; leaving one is not rejection. ## Tracing a string Take a two-state acceptor over digits for "an even number of 1s": states `E` (start, accepting) and `O`; a `1` toggles the state, every other digit leaves it alone. On input `1 0 1 1`: | step | state before | symbol | state after | |---|---|---|---| | 1 | `E` | `1` | `O` | | 2 | `O` | `0` | `O` | | 3 | `O` | `1` | `E` | | 4 | `E` | `1` | `O` | The run ends in `O`, so the string is **rejected** — it carries three 1s, an odd count. Note that the machine stood in the accepting state `E` after step 3 and that this changed nothing: only the state after the last symbol is consulted. ## Why the final state carries the whole verdict The state is a complete summary of everything read so far, in the only sense that matters: two prefixes that land in the same state are indistinguishable to the machine from then on, because the same remaining symbols drive the same transitions. That is what makes the model implementable in fixed hardware. A validator with `n` states needs only enough storage to name one of `n` values — two states is one bit — plus a table of (states x symbols) entries. It can therefore run over a stream of unbounded length inside a device with no buffer at all, which is exactly why fixed-function readers and scanners are built this way. It also explains the model's limit without any theory: whatever the machine needs to remember must fit into a finite set of labels chosen before the input is ever seen. ## Reading a machine you are handed Given a diagram or a table, answer three questions before anything else, in this order: 1. Which state is marked as the start? Everything else is relative to it. 2. Which states are marked accepting? A machine with no accepting states rejects every string, including the empty one. 3. Does every state have an outgoing arrow for every symbol? If not, the drawing is shorthand and a non-accepting sink is implied. Then trace by hand, writing down the state after each symbol instead of holding it in your head. A single skipped step is the usual reason a candidate's answer disagrees with the machine in front of them. ## Where candidates go wrong - **"It passed through an accepting state, so it accepts."** Only the state after the final symbol is consulted. - **"It got stuck, so it rejects."** A deterministic acceptor does not get stuck; rejection is a state you end in, not a failure to move. - **"The empty string is a special case."** It is not: with no symbols read the machine is still in the start state, so the empty string is accepted exactly when the start state is accepting. - **"It can decide early."** The definition consumes the whole input. An implementation may stop as soon as no remaining symbol can change the accept status, but that is an optimisation, not the model.

  • When does a deterministic finite acceptor accept the empty string?
    Exactly when its start state is an accepting state. With no symbols to read, no transition ever fires, so the run ends where it began. That is why designers who must reject empty input give the machine a separate non-accepting start state instead of starting in an accepting one.
  • Can the same string ever produce two different verdicts on the same deterministic acceptor?
    No. The transition rule is a function, so each state-and-symbol pair has one successor and the run is fully determined by the input. Repeating the run reproduces every intermediate state. Any observed difference means the machine kept state between runs, which the model forbids.
  • May an implementation stop reading before the end of the input?
    Only when the verdict is already fixed — the run has entered a state it can never leave whose accept status is therefore final. The definition still consumes every symbol; stopping early is an engineering optimisation and must not change which strings are accepted.

A clerk who may keep only a single sticky note, replacing what is written on it as each item passes. At the end of the queue, the note alone decides yes or no — no one asks what was written on it earlier.

saying these in an interview costs you the question

  • Says a string is accepted because the run visited an accepting state somewhere
  • Thinks the machine looks ahead at symbols it has not read yet
  • Believes a run can go back and re-read an earlier symbol
  • Treats the empty string as outside the model rather than a start-state question
  • Assumes the start state is accepting by default
open as a page

You have two finite automata over the same alphabet; how do you build one recogniser that accepts exactly the strings both accept?

level: middleimportance: must knowfreq 58%

basics

~20 s

Run both machines at once. The product automaton's states are pairs (p, q), one component per machine, and each input symbol advances both components. Mark a pair accepting when both components accept, and you have the intersection.

open as a page

Why must a deterministic finite acceptor define a transition for every state and symbol, including invalid ones?

level: middleimportance: must knowfreq 55%

basics

~20 s

Determinism means exactly one successor for every state-and-symbol pair, so the transition rule must be total and no run can ever get stuck. Symbols a rule forbids are usually routed to a non-accepting trap state that absorbs the rest of the input.

open as a page

In a deterministic finite acceptor for badge sequences, what makes two of its states distinguishable rather than mergeable?

level: middleimportance: must knowfreq 62%

basics

~20 s

Two states are distinguishable when some remaining input is accepted from one and rejected from the other; that string is the witness. States with no such witness behave identically on every future input and can be merged without changing the accepted language.

open as a page

In a nondeterministic finite automaton, a symbol can lead to several states or none — what does it mean to accept a string?

level: middleimportance: must knowfreq 62%

basics

~20 s

Acceptance is existential: the machine accepts a string when at least one run over it ends in an accepting state. Runs that die on a missing transition, or finish in a non-accepting state, simply contribute nothing.

open as a page

What is the epsilon-closure of a set of states in a finite automaton, and why does the subset construction need it?

level: middleimportance: must knowfreq 55%

basics

~20 s

The epsilon-closure of a state set is that set plus every state reachable from it by epsilon moves alone. Determinisation needs it because such moves consume no symbol, so those states are already live before the next symbol arrives.

open as a page

A colleague proposes one regular pattern to validate arbitrarily nested bracket expressions. What argument refutes it on the spot?

level: middleimportance: must knowfreq 70%

basics

~20 s

A finite-state recogniser has finitely many states, so it cannot track unbounded nesting depth. The pumping lemma makes that concrete: repeating a block of opening brackets inside a long balanced witness yields an unbalanced string the pattern must still accept.

open as a page

Why must a finite automaton be deterministic and total before you complement it by flipping its accepting states?

level: middleimportance: should knowfreq 45%

basics

~20 s

Flipping accepting states complements the language only for a deterministic, total machine. A missing transition leaves a rejected string with no state to flip, and flipping a nondeterministic machine answers "some run ends non-accepting" instead of "no run accepts".

open as a page

How would you design a deterministic finite acceptor that accepts exactly the digit strings divisible by three?

level: middleimportance: should knowfreq 48%

basics

~20 s

Make each state a remainder. Three states hold the value-so-far modulo three; reading digit d in remainder r moves to (10r + d) mod 3, which simplifies to (r + d) mod 3. Remainder zero is the accepting state.

open as a page

How does partition refinement collapse a six-state badge acceptor into the smallest deterministic machine accepting the same sequences?

level: middleimportance: should knowfreq 48%

basics

~20 s

Start with two blocks, accepting states and non-accepting states, then repeatedly split any block whose members send some input letter into different blocks. When no split applies, each remaining block becomes one state of the minimal machine.

open as a page

How does the subset construction turn a nondeterministic finite automaton into a deterministic one, and what is a single resulting state?

level: middleimportance: should knowfreq 48%

basics

~20 s

Each state of the deterministic machine is a whole set of nondeterministic states — exactly those a prefix could have reached. Transitions map a set to the union of its members' successors, the empty set is the trap, and a set accepts if any member does.

open as a page

A non-regularity proof picks a convenient split of its witness string and pumps that. Why is the proof invalid?

level: middleimportance: should knowfreq 46%

basics

~20 s

Choosing the decomposition is the adversary's move, not the prover's. The lemma promises only that some legal split exists, so a valid argument must defeat every split allowed by the constraints; defeating one convenient split proves nothing.

open as a page

Two teams shipped different finite automata for one message-filter rule; how do you decide whether they accept exactly the same strings?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Turn equality into emptiness. Build the product of the two machines, mark a pair accepting when exactly one component accepts, and search for a reachable accepting pair. None found means the machines agree; the first one found hands you a disagreeing string.

open as a page

In a deterministic finite acceptor for strings containing 1 1 0, why can't a mismatch reset the run to the start state?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Because the symbol that broke the match can itself begin the next one. Each state records the longest prefix of 1 1 0 that ends the input so far, so after 1 1 1 the machine must stay at two matched symbols rather than drop to zero.

open as a page

Why does partition refinement alone fail to give the smallest deterministic acceptor when some of its states are unreachable?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Refinement merges states that behave identically; it never deletes states. An unreachable state can be distinguishable from every reachable one, so it survives as its own block and inflates the result, even though no input can visit it and the accepted language is unchanged.

open as a page

A sensor accepts streams whose k-th symbol from the end is a marker — why does determinising that acceptor cost 2^k states?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Nondeterministically the machine guesses which symbol is the k-th from the end and needs only k+1 states. Deterministically nothing can guess, so it must remember which of the last k symbols were markers — and all 2^k combinations occur.

open as a page

For inputs of opening brackets then closing brackets with strictly more opens than closes, why must a pumping argument use i = 0?

level: seniorimportance: should knowfreq 36%

basics

~20 s

Repetition only adds opening brackets, which keeps the strict inequality true, so pumping upward never leaves the language. Deleting the block instead drops the opening count to the closing count or below, breaking the strict inequality and giving the contradiction.

open as a page

A gateway holds an allow rule and a deny rule, each already a finite automaton: when do you precompute one combined recogniser instead of running both per message?

level: principalimportance: should knowfreq 30%

basics

~20 s

Decide by comparing build cost against per-message cost. Combining pays when rules are stable and messages are many; running both in lockstep pays when rules change constantly, when negating the deny rule risks a state explosion, or when operators need to know which rule fired.

open as a page

When two teams must keep independently written badge acceptors in agreement forever, what does adopting the canonical minimal machine as the shared specification cost?

level: principalimportance: should knowfreq 33%

basics

~20 s

You gain a unique object: for one language the minimal acceptor is the same machine up to renaming, so agreement becomes an identity check. You pay in readability, unstable diffs, and a contract that covers acceptance only, never outputs or timing.

open as a page

When is a pumping argument worth spending on a claim that a format is not finite-state checkable, and what does a failed attempt prove?

level: principalimportance: should knowfreq 30%

basics

~20 s

A failed attempt proves nothing: the pumping property follows from being finite-state checkable but does not imply it, so failing to refute a format is not evidence for it. Spend the argument where the answer changes a design and the rule is stable.

open as a page

Given a finite automaton, how do you decide whether it accepts infinitely many strings rather than a finite set?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Finiteness is a cycle test on the useful part of the graph. Keep the states that are both reachable from the start and able to reach an accepting state; if that live sub-graph contains a cycle, the language is infinite, otherwise it is finite.

open as a page

How many states does a deterministic finite acceptor need for a stated digit rule, and how do you know?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

Count the situations the machine must tell apart, because each one is a state. A remainder rule needs one state per remainder, a parity rule two, a fixed pattern of length k needs k plus one, and a window of the last k symbols needs about s to the power k.

open as a page

Why can no complete deterministic acceptor of badge frames exactly n symbols long use fewer than n+2 states?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Because the language has n+2 Myhill-Nerode classes: one per prefix length from 0 to n, plus one for everything already too long. A machine with fewer states would place two classes on one state and then give their separating suffix the same verdict, which is impossible.

open as a page

A payload is valid only when its cell count is a perfect square. How does a pumping argument rule out finite-state validation?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Take a witness of exactly p times p cells, where p is the pumping length. The prefix bound caps the pumped block at p cells, so one extra repetition lands the length strictly between two consecutive squares — a length the rule rejects but the lemma says is accepted.

open as a page

For a line-rate stream sensor, how do you choose between simulating a nondeterministic acceptor per symbol and determinising it ahead of time?

level: principalimportance: nice to knowfreq 30%

basics

~20 s

Trade per-symbol work against memory. Simulation costs work proportional to the live state set but needs only that set; full determinisation costs one table lookup but up to 2^n states. Building subsets on demand splits the difference at the price of a bounded cache.

open as a page