So, about the DFA. Here is the algorithm I plan to use :

// DFA:
//
// 1. A finite set of states. (Set Q)
// 2. A finite set of input symbols.
// 3. A transition function (takes as argument a state and input symbol and returns a state).
// 4. A start state (one of the states in Q).
// 5. A set of final states (subset of Q).
--------
class State {
State (name of state, number of symbols) { // Constructor
Create array transition[number of symbols];
while (i < number of symbols) {
transition[i] = stdin.read (state, ith-symbol)
}
getNewState (symbol number) {
return (transition[symbol number]);
}
}
main () {
acceptableSymbolArray[nSymbols];
State state[nStates] (name of state, number of symbols)
string: #abc#abbc#
while (string does not end) {
symbol = search for symbol in acceptableSymbolArray[]
next state = state[current state].getNewState(symbol);
}
if (final state = next state) {
String accepted
}
}

---------

### Like this:

Like Loading...

*Related*

This entry was posted on September 19, 2006 at 4:32 pm and is filed under java. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

## Leave a Reply