Question

The naive implementation of a FA would have the node look like:

struct Node {
    string label;
    Node*[char] trans;
}

But what if one of your transitions is "![a]" (anything but the char 'a'). And your alphabet is too huge to store all possible chars that are not 'a'. Do you see what I mean?

Edit. My current guess is

struct NFAState {
    string label;
    Node*[][char] trans;
    Node*[][char] notTrans;
    Node*[] epsTrans;
}

for an NFA node.

Was it helpful?

Solution

You could add a second Node*[char] notTrans; and store all nodes for the not cases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top