Thread: DFA and NFA

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    134

    DFA and NFA

    What is the best data structure to implement NFA and DFA, or these two needs to be represented in diffrent data structure for efficiency? I am actually trying to convert NFA to DFA, then check weather a particular string is accepted by DFA OR NOT.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    First of all, please post some code to show where you're having trouble. second, explain what DFA and NFA are.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    134

    I have not started yet, only planning for now

    NFA= Non-deterministic Finite Automata
    DFA= Deterministic Finite Automata

    without knowing what kind of datasructure is good for such things, I can't proceed, I must get a good idea of what can be use to make it an efficient progrmming.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by kapil1089thekin View Post
    NFA= Non-deterministic Finite Automata
    DFA= Deterministic Finite Automata

    without knowing what kind of datasructure is good for such things, I can't proceed, I must get a good idea of what can be use to make it an efficient progrmming.
    That's the wrong approach, IMO. Focus on the algorithm and the necessary data structures will naturally follow.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed