DFA 和 NFA 的區別

來源:互聯網
上載者:User
         When I first read 'DFA' and 'NFA', I feel they are very complex. but when I read the concept of them, I found they are very very simple. Not complex at all.
       DFA is acronym of deterministic finite automata. You had better know what is finite automata before trying to know DFA and NFA. An automate is a mathmatical model for finite state machine. I think everyone know finite state machine well.It is just a serial of states and the trigger condition. Finite automate is this kind of state machine which will stop after a certain steps. How doest the state machine transfer state is regulating by its onwer internal  principle and the input.
  An automata is represented by the 5-tuple (set of states, finite set of symbols,transition function, start state, accepted state). You can find the detailed definition at (http://en.wikipedia.org/wiki/Automate_theory).
   The difference between DFA and NFA :
   1. Deterministic finite automate :
    Each state of an automaton of this kind has a transition for every symbol in the alphabet.
   2. Nondeterministic finite automate :
     States of an automaton of this kind may or may not have a transition for each symbol for each symbol in the alphabetet, or can even have multiple for a symbol. If a transition is undefined, so that the automaton doesn't know how to keep on reading the input, the word is rejected.
   
     我的理解就是:
    1.  DFA在任何狀態對於任何輸入都是有一個明確的處理(state transiton),  而NFA 不然。
    2. 如果輸入集合為N,狀態幾個為M,則DFA 的狀態遷移矩陣應該為N X M, 而NFA 的狀態遷移矩陣是可以儲存裁剪的。
   3. DFA 之所以比 NFA 快是因為DFA 在任何狀態都與任何輸入的處理都是確定的,而NFA 不能夠確定處理(需要藉助輔助資訊)
   4. 關於 DFA 不支援backtrack 和 NFA 支援 backtrack , 這個不是 DFA 和 NFA 的本質區別,而是由於各自的本質特性導致在實現上的差異而帶來的不同效果。就好像是一個沒有腿的人,要走路必須做電動車,結果是比有腿走路的人快,所以說沒腿的人走的快不是本質的區別。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.