Finite State Machines: GATE ECE practice questions with solutions

This topic covers Moore and Mealy machines, sequence detectors, state minimization, state assignment and next-state logic. The 15 original questions follow the GATE EC format: 9 MCQ, 2 MSQ and 4 NAT, from 5 easy, 7 medium and 3 hard.

Three ideas to know:

  • Moore outputs belong to states; Mealy outputs belong to transitions.
  • An overlapping 101 detector fires at every 1 that completes 101, even when the 101s share bits.
  • Appending a bit doubles the number and adds the bit, so only the remainder needs to be stored.

It helps GATE EC and ECE students revising Digital Circuits for the exam or a semester test. Helpful background: Moore machines and Sequence detectors. Start with the 5 easy questions, then work up to the 3 hard ones.

Q.1

EasyMCQ1 mark

The output of a Moore machine depends on

  1. Option A: the present inputs only
  2. Option B: the present state and the present inputs
  3. Option C: the present state only
  4. Option D: the next state only
Show answer and solutionHide answer and solution

Answer: (C)

Key idea: Moore outputs belong to states; Mealy outputs belong to transitions.

1. In a Moore machine each state has a fixed output.

2. The inputs only decide the next state, so the output depends on the present state alone.

Common mistake: Describing a Mealy machine, whose output depends on the state and the inputs, gives option (B).

You need: Moore and Mealy machines

Q.2

EasyMCQ1 mark

A finite state machine has 9 states and uses binary (minimum-width) state encoding. The number of flip-flops needed is

  1. Option A: 3
  2. Option B: 4
  3. Option C: 9
  4. Option D: 5
Show answer and solutionHide answer and solution

Answer: (B)

Key idea: Binary encoding needs ⌈log₂ N⌉ flip-flops for N states.

1. n flip-flops give 2ⁿ codes. 2. 2³ = 8 < 9 and 2⁴ = 16 ≥ 9.

3. So 4 flip-flops are needed.

Common mistake: Using one flip-flop per state (one-hot) gives 9, option (C).

You need: State encoding

Q.3

EasyNAT1 mark

A finite state machine with 12 states uses one-hot state encoding. The number of flip-flops is ______.

Numerical answer: type a number.

Show answer and solutionHide answer and solution

Answer: 12

Key idea: One-hot trades more flip-flops for simpler next-state logic.

1. One-hot encoding gives every state its own flip-flop, and exactly one is 1 at a time. 2. 12 states need 12 flip-flops.

Common mistake: Using binary encoding, ⌈log₂ 12⌉ = 4.

You need: State encoding, one-hot

Q.4

EasyMCQ1 mark

The minimum number of states in a Mealy machine that detects the sequence 101 with overlapping allowed (output 1 on the clock where the last 1 arrives) is

  1. Option A: 3
  2. Option B: 4
  3. Option C: 2
  4. Option D: 5
Show answer and solutionHide answer and solution

Answer: (A)

Key idea: A Mealy detector for an n-bit pattern needs at most n states, because the output sits on the transition.

1. States: no progress, seen 1, seen 10.

2. In 'seen 10', input 1 outputs 1 and goes to 'seen 1', which allows overlap.

3. So 3 states are enough, and fewer cannot remember the three useful prefixes.

Common mistake: Counting a separate 'found' state, as a Moore machine needs, gives 4, option (B).

You need: Sequence detectors, Mealy machines

Q.5

EasyMCQ1 mark

In state assignment, choosing codes so that states which follow each other differ in only one bit mainly

  1. Option A: reduces the number of flip-flops
  2. Option B: removes the need for a clock
  3. Option C: turns the machine into a Mealy machine
  4. Option D: reduces the number of bits that change per transition, cutting glitches and switching power
Show answer and solutionHide answer and solution

Answer: (D)

Key idea: A Gray-like state assignment changes how many bits switch, not how many flip-flops exist.

1. The number of flip-flops depends on the number of states and the encoding style, not on which code goes to which state.

2. Adjacent codes mean only one flip-flop changes on those transitions.

3. Fewer changing bits give fewer decoding glitches and less switching power.

Common mistake: Thinking a clever assignment saves flip-flops and choosing (A).

You need: State assignment

Q.6

MediumMCQ2 marks

The Moore machine described in the figure starts in S0. The input x = 1, 0, 1, 0, 1, 1, 0, 1 is applied, one bit per clock. The output z after each clock, in order, is

Moore machine with states S0 to S3A Moore machine with one input x, one output z and four states S0 (reset), S1, S2 and S3. Transitions: S0 goes to S0 on x = 0 and to S1 on x = 1. S1 goes to S2 on x = 0 and stays in S1 on x = 1. S2 goes to S0 on x = 0 and to S3 on x = 1. S3 goes to S2 on x = 0 and to S1 on x = 1. Outputs: z = 0 in S0, S1 and S2; z = 1 in S3.01100101S0z = 0S1z = 0S2z = 0S3z = 1edge labels: input x; inside each state: output z
  1. Option A: 00100001
  2. Option B: 01010010
  3. Option C: 00101001
  4. Option D: 00101101
Show answer and solutionHide answer and solution

Answer: (C)

Key idea: Trace the states first, then read each output from the state it is in.

1. States after each clock: S1, S2, S3, S2, S3, S1, S2, S3. 2. z = 1 only in S3, so the outputs are 0, 0, 1, 0, 1, 0, 0, 1.

3. The machine detects 101 with overlap: the 1 that ends one 101 starts the next.

Common mistake: Treating the detector as non-overlapping (starting from scratch after each detection) misses the second 101 and gives 00100001, option (A).

You need: Moore machines, sequence detectors

Q.7

MediumNAT2 marks

The Moore machine described in the figure starts in S0. For the input x = 1, 1, 0, 1, 0, 1, 0, 1, 1, 0 (one bit per clock), the number of clocks after which z = 1 is ______.

Moore machine with states S0 to S3A Moore machine with one input x, one output z and four states S0 (reset), S1, S2 and S3. Transitions: S0 goes to S0 on x = 0 and to S1 on x = 1. S1 goes to S2 on x = 0 and stays in S1 on x = 1. S2 goes to S0 on x = 0 and to S3 on x = 1. S3 goes to S2 on x = 0 and to S1 on x = 1. Outputs: z = 0 in S0, S1 and S2; z = 1 in S3.01100101S0z = 0S1z = 0S2z = 0S3z = 1edge labels: input x; inside each state: output z

Numerical answer: type a number.

Show answer and solutionHide answer and solution

Answer: 3

Key idea: An overlapping 101 detector fires at every 1 that completes 101, even when the 101s share bits.

1. States: S1, S1, S2, S3, S2, S3, S2, S3, S1, S2. 2. z = 1 in S3, which occurs after clocks 4, 6 and 8.

3. Count = 3.

Common mistake: Restarting after each detection (no overlap) finds only the 101s ending at clocks 4 and 8, giving 2.

You need: Moore machines, sequence detectors

Q.8

MediumMCQ2 marks

A Mealy machine has input x and this state table (next state / output): A: x = 0 → B/0, x = 1 → C/0. B: x = 0 → D/0, x = 1 → E/0. C: x = 0 → D/0, x = 1 → E/0. D: x = 0 → A/1, x = 1 → C/0. E: x = 0 → A/1, x = 1 → B/0. The minimum number of states in an equivalent machine is

  1. Option A: 3
  2. Option B: 4
  3. Option C: 5
  4. Option D: 2
Show answer and solutionHide answer and solution

Answer: (A)

Key idea: Equivalence is found by repeated refinement; merging one pair can make another pair equivalent.

1. B and C have identical rows, so B ≡ C.

2. D and E then have the same outputs and next states A, A and C, B, which are equivalent, so D ≡ E.

3. A differs from B: on x = 0, A goes to B and B goes to D, and D outputs 1 on x = 0 while B outputs 0.

4. The classes are {A}, {B, C}, {D, E}: 3 states.

Common mistake: Merging only the identical rows B and C, and not noticing that D and E then match, gives 4, option (B).

You need: State minimization

Q.9

MediumMCQ1 mark

The output of a Mealy machine can change

  1. Option A: only at active clock edges
  2. Option B: whenever an input changes, even between clock edges
  3. Option C: never, once the machine is reset
  4. Option D: only when the machine is reset
Show answer and solutionHide answer and solution

Answer: (B)

Key idea: Mealy outputs react to inputs immediately; Moore outputs change only with the state.

1. A Mealy output is a function of the present state and the present inputs.

2. The inputs can change at any time, so the output can change between clock edges.

Common mistake: Describing a Moore machine, whose output changes only at clock edges, gives option (A).

You need: Mealy machines, timing

Q.10

MediumMSQ2 marks

A Mealy machine and a Moore machine both detect the same input pattern. Which of the following statements are true?

One or more options are correct.

  1. Option A: The Mealy machine always needs more flip-flops
  2. Option B: The Moore machine may need more states
  3. Option C: The Moore machine's output depends directly on the present input
  4. Option D: For the same input stream, the Moore machine raises its detection output one clock later than the Mealy machine
Show answer and solutionHide answer and solution

Answer: (B) and (D)

Key idea: Moore = output in the state, one clock later; Mealy = output on the transition.

1. A Mealy machine never needs more states, so (A) is false.

2. A Moore machine needs a separate state for 'just detected', so it may need more states: (B) true.

3. Moore outputs depend only on the state: (C) false.

4. The Moore output appears when the machine enters the detecting state, one clock after the Mealy output, which appears on the transition: (D) true.

Common mistake: Reversing the two machine types and choosing (A) and (C).

You need: Moore and Mealy machines

Q.11

MediumNAT1 mark

The minimum number of states in a Moore machine that detects the sequence 1101 with overlapping allowed is ______.

Numerical answer: type a number.

Show answer and solutionHide answer and solution

Answer: 5

Key idea: A Moore detector for an n-bit pattern needs n + 1 states: one per prefix plus the output state.

1. One state for each prefix that has been matched: none, 1, 11, 110.

2. A Moore machine also needs a state that outputs 1 after 1101 has been seen.

3. Total 5.

Common mistake: Using the Mealy count of 4, without a state that holds the output.

You need: Sequence detectors, Moore machines

Q.12

MediumMCQ2 marks

A Mealy machine outputs 1 whenever the last four inputs are 0110, with overlapping allowed. For the input stream 0110110110, how many times is the output 1?

  1. Option A: 1
  2. Option B: 2
  3. Option C: 4
  4. Option D: 3
Show answer and solutionHide answer and solution

Answer: (D)

Key idea: With overlap, the end of one pattern can be the start of the next.

1. The pattern ends at positions 4, 7 and 10 (counting from 1): 0110 110 110 contains 0110 at bits 1 to 4, 4 to 7 and 7 to 10.

2. Each occurrence shares its first 0 with the last 0 of the previous one.

3. Total 3.

Common mistake: Resetting after each detection (non-overlapping) finds 0110 at bits 1 to 4 and 7 to 10 only, giving 2, option (B).

You need: Sequence detectors, Mealy machines

Q.13

HardNAT2 marks

A Moore machine reads an unsigned binary number one bit per clock, MSB first, and its state is the remainder of the number read so far divided by 5 (states 0 to 4, starting in 0). After the input 1, 1, 0, 1, 1, 0, the state is ______.

Numerical answer: type a number.

Show answer and solutionHide answer and solution

Answer: 4

Key idea: Appending a bit doubles the number and adds the bit, so only the remainder needs to be stored.

1. Reading bit b from remainder r gives the new remainder (2r + b) mod 5. 2. 1 → 1; 1 → 3; 0 → 6 mod 5 = 1; 1 → 3; 1 → 7 mod 5 = 2; 0 → 4.

3. Check: 110110₂ = 54 and 54 mod 5 = 4.

Common mistake: Reading the bits LSB first, as 011011₂ = 27, gives 27 mod 5 = 2.

You need: FSM design, modular arithmetic

Q.14

HardMCQ2 marks

The Moore machine in the figure is built with two D flip-flops Q1 Q0 using the assignment S0 = 00, S1 = 01, S2 = 10, S3 = 11. The minimal sum of products for D1 in terms of Q1, Q0 and x is

Moore machine with states S0 to S3A Moore machine with one input x, one output z and four states S0 (reset), S1, S2 and S3. Transitions: S0 goes to S0 on x = 0 and to S1 on x = 1. S1 goes to S2 on x = 0 and stays in S1 on x = 1. S2 goes to S0 on x = 0 and to S3 on x = 1. S3 goes to S2 on x = 0 and to S1 on x = 1. Outputs: z = 0 in S0, S1 and S2; z = 1 in S3.01100101S0z = 0S1z = 0S2z = 0S3z = 1edge labels: input x; inside each state: output z
  1. Option A: Q0x′ + Q1x
  2. Option B: Q1′Q0x′ + Q1Q0′x
  3. Option C: Q0x′ + Q1Q0′x
  4. Option D: Q1 ⊕ x
Show answer and solutionHide answer and solution

Answer: (C)

Key idea: Build the next-state map for each flip-flop from the state table, then minimize it like any function.

1. The next states with Q1⁺ = 1 are S2 or S3.

2. These are reached from S1 on x = 0 (Q1Q0x = 010), from S2 on x = 1 (101) and from S3 on x = 0 (110). 3. 010 and 110 merge into Q0x′. 4. 101 stays alone: Q1Q0′x.

5. D1 = Q0x′ + Q1Q0′x.

Common mistake: Forgetting that S3 goes to S1 (Q1⁺ = 0) on x = 1 treats 111 as a 1 and lets 101 and 111 merge into Q1x, giving option (A).

You need: FSM implementation, K-maps

Q.15

HardMSQ2 marks

Which of the following statements about the machine in the figure are true?

Moore machine with states S0 to S3A Moore machine with one input x, one output z and four states S0 (reset), S1, S2 and S3. Transitions: S0 goes to S0 on x = 0 and to S1 on x = 1. S1 goes to S2 on x = 0 and stays in S1 on x = 1. S2 goes to S0 on x = 0 and to S3 on x = 1. S3 goes to S2 on x = 0 and to S1 on x = 1. Outputs: z = 0 in S0, S1 and S2; z = 1 in S3.01100101S0z = 0S1z = 0S2z = 0S3z = 1edge labels: input x; inside each state: output z

One or more options are correct.

  1. Option A: It is a Moore machine
  2. Option B: With one-hot encoding it needs 4 flip-flops
  3. Option C: Starting from S0, the input 1, 0, 1, 0, 1 makes z = 1 after exactly 2 of the 5 clocks
  4. Option D: It has a state that cannot be reached from S0
Show answer and solutionHide answer and solution

Answer: (A), (B) and (C)

Key idea: Read the machine type from where the outputs are written, then trace any input clock by clock.

1. The output is attached to the states, so it is a Moore machine: (A) true.

2. Four states, one flip-flop each: (B) true.

3. States: S1, S2, S3, S2, S3, so z = 1 after clocks 3 and 5: (C) true.

4. S1, S2 and S3 are all reached in that trace, so every state is reachable: (D) false.

Common mistake: Missing the overlap and counting only one detection makes (C) look false.

You need: Moore machines, state encoding