先决条件 – 有限自动机
1. DFA:
DFA 指的是确定性有限自动机。有限自动机(FA)被认为是确定性的,如果对应于一个输入符号,则存在单个结果状态,即只有一个转换。
确定性有限自动机由五个元组组成,表示为,
在哪里,
Q:有限控制(qo,q1,q2,…)中存在的非空有限状态集。
Σ:一个非空的有限输入符号集。
δ:它是一个转换函数,它有两个参数,一个状态和一个输入符号,它返回一个状态。
qo:是起始状态,Q中的状态之一。
F:它是属于 Q 的集合中的最终状态/接受状态的非空集。
2. NFA:
NFA 指的是非确定性有限自动机。如果在同一输入符号上从一种状态有不止一种可能的转换,则称有限自动机 (FA) 是非确定性的。
非确定性有限自动机也由五个元组组成,表示为,
在哪里,
问:一组非空的有限状态。
Σ:一组非空的有限输入符号。
δ:它是一个转移函数,它从 Q 中获取一个状态和一个输入符号,并返回 Q 的一个子集。
qo:NFA 的初始状态和 Q 的成员。
F:一组非空的最终状态和 Q 的成员。
DFA和NFA的区别:
SR.NO. | DFA | NFA |
---|---|---|
1 | DFA stands for Deterministic Finite Automata. | NFA stands for Nondeterministic Finite Automata. |
2 | For each symbolic representation of the alphabet, there is only one state transition in DFA. | No need to specify how does the NFA react according to some symbol. |
3 | DFA cannot use Empty String transition. | NFA can use Empty String transition. |
4 | DFA can be understood as one machine. | NFA can be understood as multiple little machines computing at the same time. |
5 | In DFA, the next possible state is distinctly set. | In NFA, each pair of state and input symbol can have many possible next states. |
6 | DFA is more difficult to construct. | NFA is easier to construct. |
7 | DFA rejects the string in case it terminates in a state that is different from the accepting state. | NFA rejects the string in the event of all branches dying or refusing the string. |
8 | Time needed for executing an input string is less. | Time needed for executing an input string is more. |
9 | All DFA are NFA. | Not all NFA are DFA. |
10 | DFA requires more space. | NFA requires less space then DFA. |
11. | Dead state may be required. | Dead state is not required. |
12. | δ: QxΣ -> Q i.e. next possible state belongs to Q. | δ: QxΣ -> 2^Q i.e. next possible state belongs to power set of Q. |