0

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.

  • Are you programming in C or C++? – RaphMclee Sep 15 '13 at 06:12
  • D. Node*[char] is a built-in hash-table associative array. So trans['a'] will point to the state given the current node and input 'a'. –  Sep 15 '13 at 06:13
  • 1
    What about storing `-'a'` in the original struct design? Do you also thought about the hardcoded FA? Or if the FA is acyclic, you can use bitstream implementation. – bartimar Sep 15 '13 at 06:37
  • @bartimar: What do you mean by bitstream impl? –  Sep 15 '13 at 07:31
  • I see what you mean, from a paper. I guess I will save that idea for the DFA. NFA useage would mean in multiple states at once, which wouldn't take advantage of the ordering of states in memory. –  Sep 15 '13 at 07:44
  • Oh, I thought we are talking about DFA all the time :) sorry :) – bartimar Sep 15 '13 at 20:30

1 Answers1

0

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

RaphMclee
  • 1,623
  • 13
  • 16