+14 votes
1.7k views

The smallest finite automaton which accepts the language $\{x |$ length of $x$ is divisible by $3\}$ has

1. $2$ states
2. $3$ states
3. $4$ states
4. $5$ states
asked
edited | 1.7k views
0
Modulo 3 gives remainder as ( 0, 1, 2 )

3 states needed

3 Answers

+21 votes
Best answer

Answer (B). It is $3$ states as we need a state each for length mod $3 = 0, 1$ and $2$.

answered by (191 points)
edited
0

Can anybody please explain why 2 states is wrong answer ?

Please find the below diagram in reference to my query.

0
@Sid Try string "1". It will be accepted by your machine though length of string isn't divisible by 3.

General formula: a (mod n) then we will have n states in minimal DFA, which is unique. If DFA isn't minimal we may have more number of states.
0
Yes now I understand the point.

My answer would be applicable for length as odd number rather than as divisible by 3.
0
@Sid Yes for the odd number it is applicable with q0 as starting state.
+1

In the question it is saying {x | length of the x is divisible by 3}  not the x itself is divisible by 3 . So, the

answer should be B. 3 states but diagram would be

0

what about length 0,why initial state is final state?

+2 votes

Option B is Correct

answered by Active (4.1k points)
+1 vote

Correct option is B.

answered by Active (1.7k points)
Answer:

+18 votes
1 answer
1
+18 votes
1 answer
2
+16 votes
2 answers
3
+14 votes
1 answer
4
+21 votes
2 answers
5
+20 votes
3 answers
6
+18 votes
5 answers
7