# NFA to DFA Conversion

Email
 Submitted on: 1/8/2015 6:49:00 AM By: Ritin (from psc cd) Level: Advanced User Rating: By 2 Users Compatibility: C, C++ (general) Views: 15734

It is a program for NFA ( Non-deterministic Finite Automata) to DFA (Deterministic Finite Auctomata ) Conversion using the Subset Construction Algorithm.

code:
Can't Copy and Paste this?
 ``` //************************************** // Name: NFA to DFA Conversion // Description:It is a program for NFA ( Non-deterministic Finite Automata) to DFA (Deterministic Finite Auctomata ) Conversion using the Subset Construction Algorithm. // By: Ritin (from psc cd) // // Inputs:NFA states, inputs, transitions // // Returns:DFA transition table //************************************** //NFA to DFA conversion #include #include #define STATES 50 struct Dstate { char name; char StateString[STATES+1]; char trans[10]; int is_final; }Dstates[50]; struct tran { char sym; int tostates[50]; int notran; }; struct state { int no; struct tran tranlist[50]; }; int stackA[100],stackB[100],C[100],Cptr=-1,Aptr=-1,Bptr=-1; struct state States[STATES]; char temp[STATES+1],inp[10]; int nos,noi,nof,j,k,nods=-1; void pushA(int z) { stackA[++Aptr]=z; } void pushB(int z) { stackB[++Bptr]=z; } int popA() { return stackA[Aptr--]; } void copy(int i) { char temp[STATES+1]=" "; int k=0; Bptr=-1; strcpy(temp,Dstates[i].StateString); while(temp[k]!='\0') { pushB(temp[k]-'0'); k++; } } int popB() { return stackB[Bptr--]; } int peekB() { return stackA[Bptr]; } int peekA() { return stackA[Aptr]; } int seek(int arr[],int ptr,int s) { int i; for(i=0;i<=ptr;i++) { if(s==arr[i]) return 1; } return 0; } void sort() { int i,j,temp; for(i=0;istackB[j+1]) { temp=stackB[j]; stackB[j]=stackB[j+1]; stackB[j+1]=temp; } } } } void tostring() { int i=0; sort(); for(i=0;i<=Bptr;i++) { temp[i]=stackB[i]+'0'; } temp[i]='\0'; } void display_DTran() { int i,j; printf("\n\t\t DFA Transition Table "); printf("\n\t\t -------------------- "); printf("\nStates\tString\tInputs\n "); for(i=0;i

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)