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

Discussion

Simulating an NFA directly on an input of length n with m states costs roughly

  • A.order m time
  • B.order n times m squared time in the worst case
  • C.order n time
  • D.order two to the m time

Answer: B

Each input character requires computing the moves and epsilon closure of a set of at most m states. Converting to a DFA first trades construction time for scanning that costs only order n. For a scanner run on every compilation that trade is almost always worth making.

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

Post your comment

Please log in or register to post a comment.