Java Algo -1

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
	}
}
---------
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: