简体   繁体   English

为字符串{0,1}设计一个DFA,该字符串在反转时等于2 mod 7的十进制数吗?

[英]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. 首先,我们设计一个自动机,它接受一个二进制形式的字符串,该字符串等效于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. 由于7是质数,因此此自动机的状态分别为0和1分别带有一个流入的箭头和一个流出的箭头。只需反转箭头,将q2设为开始状态,将q0设为最终状态,您便得到了答案。

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. 请注意,即使您更改基数或字母,上述构造也可以解决所有类似类型的问题,唯一的问题是,对于非基数基数,它可能会变为NFA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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