MCS-212 · Block 2 Unit 2

Automata and Languages

Section 7 of 8

Block 2 · Unit 2Automata and Languages11 min · Section 7 of 8

2.7Finite automata with output: Mealy and Moore machines

Covers IGNOU MCS-212 §2.4.3, Examples 17–19

A DFA only answers “yes” or “no”. Many real devices instead produce an output at every step: a vending machine releases items, a traffic controller switches lights, a serial decoder outputs bits. Mealy and Moore machines are finite automata that write an output symbol as they run.

MealyMoore
Output attached totransitions (a/xa/x on edges)states (q/xq/x in circles)
Output length for input of length nnnnn+1n + 1 (first output at start)
Final statesnonenone
Typical usesequence detectors, serial transducerscontrollers where each state is a configuration (traffic lights)

The two models are equivalent: for every Mealy machine there is a Moore machine producing the same output (apart from the extra first symbol), and vice versa.

The elevator controller of Example 17 is another finite machine without accepting states: its six states (waiting on floor 1 or 2, about to go up or down, moving up or down) and inputs (no call, call to 1, call to 2) describe the control logic, and its outputs are the motor actions.

Key takeaways

  • Mealy: output on each transition (a/xa/x); Moore: output on each state (q/xq/x).
  • For input of length nn: Mealy gives nn outputs, Moore n+1n + 1.
  • No final states; the purpose is translation, not acceptance.
  • Mealy and Moore machines are equivalent in power.

Practice questions

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

Question 1 · multiple choice

Where is the output written in a Moore machine?

Show answer

Answer: B. Inside each state

A Moore machine’s output depends only on the current state. Output on transitions describes a Mealy machine.

Question 2 · multiple choice

A Mealy machine reads an input of length 7. How many output symbols does it produce?

Show answer

Answer: A. 7

One output per transition, so one per input symbol. Option 2 is the Moore machine’s count.

Question 3 · multiple choice

In the babbab-counting Mealy machine, which transition outputs 1?

Show answer

Answer: D. 2→b12 \xrightarrow{b} 1

State 2 means “the last two symbols were baba”; reading bb completes babbab. Option 2 only reaches "baba".

Question 4 · multiple choice

What does the babbab counter output for the input bababbabab?

Show answer

Answer: B. 00101

babbab ends at positions 3 and 5 (overlapping). Option 1 misses the overlapping second occurrence.

Question 5 · multiple choice

Which statement is true?

Show answer

Answer: C. Mealy and Moore machines are equivalent in power

Each type can simulate the other. Option 4 is false: a Moore machine outputs the start state’s symbol at once.

Question 6 · short answer

Design a Mealy machine over {0,1}\{0, 1\} that outputs 1 whenever the current input equals the previous input, and 0 otherwise (output 0 for the first symbol). Trace 00110011.

Show worked answer

States: ss (start, nothing read), p0p_0 (previous was 0), p1p_1 (previous was 1). Transitions: s→0/0p0s \xrightarrow{0/0} p_0, s→1/0p1s \xrightarrow{1/0} p_1, p0→0/1p0p_0 \xrightarrow{0/1} p_0, p0→1/0p1p_0 \xrightarrow{1/0} p_1, p1→1/1p1p_1 \xrightarrow{1/1} p_1, p1→0/0p0p_1 \xrightarrow{0/0} p_0. Trace 00110011: s→0/0p0→0/1p0→1/0p1→1/1p1s \xrightarrow{0/0} p_0 \xrightarrow{0/1} p_0 \xrightarrow{1/0} p_1 \xrightarrow{1/1} p_1; output 01010101.

↑ ↓ move↵ openTab switch type