문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top