2012-08-14 78 views
2

如标题所示,我希望有人帮助我编码将NFA转换为DFA。我只需要伪代码。我尝试过使用Google进行搜索,甚至找到了完整的源代码,但是没有什么资源可以帮助我为转换提供正式的方法(用书面文字,而不是图片)。这是一个家庭作业问题,我已经过了截止日期,所以我真的需要一些利他主义。用于将NFA转换为DFA的伪代码

谢谢。

回答

6

我写过关于此主题的文章。

Converting a NFA to a DFA by subset construction

,还包括如何做的改造,以及伪代码。

基本上算法是,开始与NFA的起始状态:

Perform closure on the current state set 
For each input symbol do the GOTO operation on the closure set. 
    If the state set you get from the GOTO is not empty 
     Do a closure of the state set. 
     If it is a new set of states: 
     add a transition between the state sets on the input 
     repeat the entire operation on this new set 
     Else 
     add a transition between the state sets on the input 

这样做,直到不再有套或转换添加。这是一个难以解释的算法,但如果您完成了两个基本操作CLOSUREGOTO,则不是很难。