Why the conversion of an NFA to DFA is useful?

481 Views Asked by At

Can someone tell me some reasons why the conversion of an NFA to DFA is useful? Until now I have found the following reasons (I am not sure of them):

  1. DFAs are faster than the NFAs
  2. DFAs are easier to implement

Does anyone know another reason why this conversion is useful?

1

There are 1 best solutions below

3
Max On

DFAs are faster than the NFAs

Yes and no.

On the one hand a given DFA of course runs "faster" than a given NFA, as an algorithm running an NFA needs to resolve the non-determinism in some way (e.g. by building the powersets at runtime).

On the other hand no: A DFA that is equivalent to a NFA will also likely be quite a lot bigger than the NFA, especially when derived by the NFA using powerset construction. This way the runtime of both will be pretty much the same.

But I'd argue that is pretty much besides the point here. We are talking about abstractions of computation we use to solve theoretic problems. We never implement a DFA on a "real" computer, so be don't really need to worry about speeds.

DFAs are easier to implement

This is a bit confusing. Do you mean it is easier to come up with a DFA that does X than an NFA that does X? I heavily disagree with this, sometimes NFAs are the better tool to tackle a problem than a DFA, sometimes a DFA is enough.

If you mean it is easier to implement an algorithm that runs those automatas you are right, for a DFA you simply follow the transition function.


Back to your main question. Why convert?

In short: If you want to run an NFA, you have to remove the non-determinism, else a deterministic algorithm can't execute it. The question is who does it. An algorithm that can run NFAs will do that for you, if you don't have that tool at hand you need to convert it beforehand.