简体   繁体   中英

Design a DFA for a string {0,1} which when reversed is decimal equivalent of 2 mod 7?

字符串 { 0,1 }设计DFA ,该字符串在反转时等于2 mod 7的 十进制等效值?

First we design an automata that accepts a string which in binary is equivalent to 2 mod 7.

We should have seven stated.

q0 -> 0 -> q0
q0 -> 1 -> q1
...
qn -> 0 -> q(2n mod 7)
qn -> 0 -> q(2n+1 mod 7)
...
q6 -> 0 -> q5
q6 -> 1 -> q6

q0 is start state, q2 is final state.

Since 7 is prime, this automata has states with exactly one in-coming arrow and exactly one out-going arrow for each 0 and 1. Just reverse the arrows, make q2 the start state and q0 the final state and you have your answer.

Note that above construction works all similar type of problems, even if you change the base or alphabet, only thing is it might become NFA for non-prime bases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM