Machine-translated by Google. Questions are authored in English.
Top

Discussion

Running a DFA on an input of length n costs

  • A.order n squared time because of the retraction on failure
  • B.order two to the n time in the worst case
  • C.order n time regardless of the number of states
  • D.order n times m time where m is the number of states

Answer: C

The automaton makes exactly one transition per character, each a single table lookup. This linear behaviour is the reason scanners convert to a deterministic machine before scanning begins. Nondeterministic simulation would multiply that cost by the number of active states.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.