In: Computer Science
BRING 4 CHALLENGING QUESTION WITH SOLUTION FOR THE FOLLOWING QUESTION
1. Using MOD function with concept explanation for DFA ( DFA WITH MODE FUNCTION)
Please do not upload simple question and question that available on the internet .....it must be challenging
Thank you
Question 1
Construct DFA for the language L = {w | w ∈ {a,b}* and Na(w) mod 3 = Nb (w) mod 3}.
Note: L={w | Na(w) = Nb(w)mod 3} which means all string contain modulus of count of a’s equal to modulus of count of b’s by 3.
Eg:
Input: a a b b b
Output: NOT ACCEPTED
Because n = 2, m=3 (2 mod 3! = 3 mod 3)
Input: a a b b
Output: ACCEPTED
Because n = 2, m = 2 (2 mod 3 = 2 mod 3)
Solution:(Step by step)
DFA State Transition Diagram:
Question 2
Design a deterministic finite automata (DFA) for accepting the language
Regular expression for above language L is,
Input: a a b b b Output: ACCEPTED // n = 2 (even) m=3 (>=1) Input: a a a b b b Output: NOT ACCEPTED // n = 3 (odd), m = 3
Solution:
Any other combination result is the rejection of the input string.
DFA State Transition Diagram:
Question 3:
Construct a DFA which accept the language L = {anbm | n > =1, (m) mod 3 = 1}.
When it comes to solution always keep the below point:
" which means any no of elements, and which means any no of elements greater than 1."
Input: a a b b b Output: NOT ACCEPTED // n = 2 (>=1), m=3 ((3) mod3 != 1) Input: a a a b Output: ACCEPTED // n = 3 (>=1), m = 1 ((1) mod 3= 1)
DFA State Transition Diagram:
Question 4:
Construct a DFA to accept all strings which satisfy w(x)mod 5 =2 .
Lets go directly to the transition diagram now:
State | 0(Input alphabet) | 1(Input aphabet) |
q0 | q0 | q1 |
q1 | q2 | q3 |
*q2 | q4 | q0 |
q3 | q1 | q2 |
q4 | q3 | q4 |
Now by above state table draw DFA and make q2 as a final state bcz w(x)mod5=2
The state diagram
Above mentioned some of the challenging questions in the field of NFA which I felt good. Also all are related with mod.