Skip to content
Official PYQ · 2005

GATE CS 2005 Q63 — Regular Expressions and Finite Automata

Explain with AI

The following diagram represents a finite state machine which takes as input a binary number from the least significant bit.

     

Which of the following is TRUE?

Choose one option
View worked solution

Answer: B

To understand the behavior of the given finite state machine, let us trace its transitions from the initial state (let's call it S0S_0) when processing a binary number from the Least Significant Bit (LSB) to the Most Significant Bit (MSB).

Standard 2's Complement Algorithm

To find the 2's complement of a binary number starting from the LSB:

  • Scan the bits from right to left (LSB to MSB).
  • Keep all leading 00s and the first 11 unchanged.
  • Invert all the remaining bits after the first 11 (i.e., 0→10 \to 1 and 1→01 \to 0).

Tracing the State Machine

Let the initial state be S0S_0 and the second state be S1S_1:

  1. In state S0S_0 (before encountering the first 11):
    • An input of 00 produces an output of 00 and keeps the machine in S0S_0.
    • An input of 11 produces an output of 11 and transitions the machine to S1S_1.
  2. In state S1S_1 (after encountering the first 11):
    • An input of 00 produces an output of 11 and keeps the machine in S1S_1.
    • An input of 11 produces an output of 00 and keeps the machine in S1S_1.

Example Trace

Consider the input decimal number 66, which is represented in binary as 1102110_2. Reading from LSB to MSB, the input sequence is 0→1→10 \to 1 \to 1:

  • Input 00: Machine is in S0S_0, outputs 00, remains in S0S_0.
  • Input 11: Machine is in S0S_0, outputs 11, transitions to S1S_1.
  • Input 11: Machine is in S1S_1, outputs 00, remains in S1S_1.

The output sequence from LSB to MSB is 0→1→00 \to 1 \to 0, which represents the binary number 0102010_2 (decimal 22).

Since the 2's complement of 66 (1102110_2) is indeed 22 (0102010_2), the machine correctly computes the 2's complement of the input binary number.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions