Assignment-1-Renas H. Darweesh
Assignment-1-Renas H. Darweesh
Darweesh
Q1:
All the strings that consist of the symbols 0 and 1 where the amount of 0’s is divisible by
2 (even amount of 0’s) and the amount of 1’s is divisible by 3.
Solution:
1. Create machine for each one of my alphabets separately following requirements
asked in the question
2. Combine both machines.
3. Convert NFA to DFA by using algorithm that we got on the lecture.
4. Select new final state to accept string that contain even amount of 0’s and 1’s
divisible by 3.
1
Assignment-1- Renas H. Darweesh
All the strings that consist of the symbols 0 and 1 where the given number is divisible by
6. For example, 0, 110, 1100, …
Solution:
1. Create machine accepts strings that are divisible by 3 and making its q 0 as initial
and final state.
2. Create new transition “0” from q0 to a new state and make it as a new final state
because if we add zero to the end of any binary number that’s divisible by 3 that
number will be changed to a number that’s divisible by 6, and q 0 remain only as
an initial state.
All the strings that consist of the decimal numbers 0 to 9 where given input is divisible by
6. For example, 0,6, 12, 18, ...
Solution:
1. Create q0 state and set it as an initial and final with a transition of number 6 to itself
because (6%6) is equal to zero so the transition of number (6) should end at q0.
Result of Mod operation shows as the state that we should create transition between it
and current state.
2. Same operation (number%6) will be done for all numbers from 0 to 9 and following
is the results:
0%6=0 transition with 0 from q0 to q0.
1%6=1 transition with 1 from q0 to q1.
2%6=2 transition with 2 from q0 to q2.
3%6=3 transition with 3 from q0 to q3.
4%6=4 transition with 4 from q0 to q4.
5%6=5 transition with 5 from q0 to q5.
6%6=0 transition with 6 from q0 to q0.
2
Assignment-1- Renas H. Darweesh
3
Assignment-1- Renas H. Darweesh
Q2:
Convert the following NFAs into DFAs:
Solution:
4
Assignment-1- Renas H. Darweesh
Q3:
1. a (a | b) * a
Solution:
L = {aa, aaa, aba, aaba, abba, aabaa, …}
2. (a | b) * a (a | b) (a | b)
Solution:
L = {aaa, aaaa, babb, baab, aabb, baba, …}
3. (aa | bb) * ((ab | ba) (aa | bb) * (ab | ba) (aa | bb) *) *
Solution:
L = {aa, abab, baba, abba, baab, aaabaaabaa, bbbabbaabaaabb, …}