Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the TM described below for computing 2’s complement using a transition diagram. In this diagram few of the transition input entries are missing and are denoted by I, II and III.

Turing machine transition diagram: q0 with self-loops (0, 1, R) and (1, 0, R) goes to q1 on (B, B, L); q1 has a self-loop labelled III and two arrows labelled I and II to the accepting state q2

Here L represents left, R represents right and N represents Accept (No movement)

Which of the following is exact replacement for I, II and III above in the order.

  • A.(0, 1, N), (B, 1, N), (1, 0, L)
  • B.(0, 0, N), (B, 1, N), (1, 0, R)
  • C.(1, 0, N), (B, 0, N), (0, 1, R)
  • D.(1, 1, N), (B, 0, N), (0, 1, L)

Answer: A

The missing entries are (0, 1, N), (B, 1, N), (1, 0, L).

The two's complement of a binary number is its ones' complement plus 1. In state q0 the machine moves right inverting every bit, (0, 1, R) and (1, 0, R), which forms the ones' complement. At the blank after the number it turns back left into q1.

In q1 it adds 1 starting from the rightmost bit. A 1 plus 1 gives 0 with a carry, so it writes 0 and keeps moving left: III = (1, 0, L). A 0 plus the carry gives 1 with no further carry, so it writes 1 and accepts: I = (0, 1, N). If the carry runs past the leftmost bit onto the blank, it writes 1 there and accepts: II = (B, 1, N).

The other options either do not write the carry correctly or move right, away from the bits still to be processed.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.