用于将NFA转换为DFA的伪代码

时间:2012-08-14 14:47:51

标签: dfa nfa

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

感谢。

1 个答案:

答案 0 :(得分:7)

我写了一篇关于这个主题的文章。

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,则不是很难。

相关问题