The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+17 votes

Consider a DFA over $\Sigma=\{a,b\}$ accepting all strings which have number of a's divisible by $6$ and number of $b$'s divisible by $8$. What is the minimum number of states that the DFA will have?

- $8$
- $14$
- $15$
- $48$

+24 votes

Best answer

Answer is (**D**). It can be proved using Myhill Nerode theorem. We need a separate state for $\#a \ mod \ 6 = 0..5$ and $\#b \ mod \ 8 = 0..7 $. Each combination of them must also be a new state giving $6*8 = 48$ minimum states required in the DFA.

Reading Myhill-Nerode theorem might be confusing though it is actually very simple.

http://courses.cs.washington.edu/courses/cse322/05wi/handouts/MyhillNerode.pdf

what would be an answer if I change the given condition to "number of a's divisible by 6 or number of b's divisible by 8"

same 48 states ..no of final states increased and .. if they asked for same symbol then we have to take lcm

**if they asked for same symbol then we have to take lcm**

explain this sid1221

i mean that set2018

https://gateoverflow.in/1227/gate2007-29?state=comment-6749&show=6749#c6749

+15 votes

Answer is D: 6 states for a's and 8 states for b's, and condition is AND so number of states will be 6X8 = 48 states.

+4 votes

**I will give a short trick for divisibility: |w| i.e length of string is divisible by a,b.**

If a doesn't divide b and b doesn't divide a then Min. states = a*b

Case 1 : Divisible by a and b ----> If a divides b or b divides a then Min. No .of states = LCM(a,b)

Case 2: Divisible by a or b ------> If a divides b or b divides a then Min. states = GCD(a,b)

@amitabh, you are wrong in case of Divisible by **a or b** , for example just check divisible by 2 or 3 and we require atleast 6 states in min. dfa but your answer gives GCD(2,3) = 1

Pls check for your multiplication part too.as i am not sure though.

anyone verify this"

**I will give a short trick for divisibility: |w| i.e length of string is divisible by a,b.**

If a doesn't divide b and b doesn't divide a then Min. states = a*b

Case 1 : Divisible by a and b ----> If a divides b or b divides a then Min. No .of states = LCM(a,b)

Case 2: Divisible by a or b ------> If a divides b or b divides a then Min. states = GCD(a,b)

"

–1 vote

- All categories
- General Aptitude 1.2k
- Engineering Mathematics 4.8k
- Digital Logic 2k
- Programming & DS 3.5k
- Algorithms 3k
- Theory of Computation 3.8k
- Compiler Design 1.5k
- Databases 2.8k
- CO & Architecture 2.5k
- Computer Networks 2.9k
- Non GATE 940
- Others 1.2k
- Admissions 320
- Exam Queries 409
- Tier 1 Placement Questions 17
- Job Queries 52
- Projects 8

34,170 questions

40,845 answers

115,883 comments

39,703 users