The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
1. MTH 401: Theory of Computation August 17, 2016
Department of Mathematics and Statistics Time: 10 minutes
Indian Institute of Technology - Kanpur Maximum Score: 10
Quiz
Name
Roll Number
Let Σ = {0, 1}. Draw a deterministic finite state machine, M = (Q, Σ, δ, q0, F) that accepts
the language containing binary strings that are not divisible by 3. In other words, draw M
with
L(M) = L = {w ∈ Σ∗
: w = (n)2 for some n ∈ N such that 3 | n}.
Note that (n)2 denotes the binary representation of n and the symbol k | n denotes that k
does not divide n. Justify your answer. [10]
Solution: We need three states to keep track of the remainder as we read through the
symbols of the binary number. Thus,
Q = {0, 1, 2}
where the label i indicate that the current remainder is i. The start state, obviously, is 0
and the set of final states is clearly F = {1, 2}.
The first few step in the evolution of the remainder is shown in the figure below:
More generally, to understand the transitions, let w be a string of length k such that w = (n)2.
Then, clearly,
n =
k
i=1
w(i)2k−i
.
2. 2
(for example, if w = 101, then (1)22
+(0)21
+(1)20
= 5.) Therefore, the string w0 correspond
to
k
i=1
w(i)2k+1−i
+ (0)20
= 2
k
i=1
w(i)2k−i
= 2n
and for the string w1, we have
k
i=1
w(i)2k+1−i
+ (1)20
= 2
k
i=1
w(i)2k−i
+ 1 = 2n + 1.
Now, if w = (n)2 is divisible by 3, i.e., n = 3m for some m, then 2n = 2(3m) = 3(3m) is still
divisible by 3 whereas 2n + 1 = 2(3m) + 1 = 3(2m) + 1 leaves remainder 1 when divided by
3. Thus,
δ(0, 0) = 0 and δ(0, 1) = 1
Similarly, if n = 3m + 1 for some m, then 2n = 2(3m + 1) = 3(2m) + 2, whereas 2n + 1 =
2(3m + 1) + 1 = 3(m + 1). Thus,
δ(1, 0) = 2 and δ(1, 1) = 0
Finally, for an n of the form n = 3m + 2 for some m, 2n = 2(3m + 2) = 3(2m + 1) + 1 and
2n + 1 = 2(3m + 2) + 1 = 3(2m + 1) + 2 and hence,
δ(2, 0) = 1 and δ(2, 1) = 2.
Thus, the finite state machine, M can be drawn as shown in the figure below: