Instantly share code, notes, and snippets.

# kipawa/gist:10fec56cab1f8d0c33a9 Created Jan 21, 2015

A simple and basic program in C to convert NFA to DFA (does not handle null moves)
 /* A program to convert NFA to DFA using conversion table Author - Kipawa Technique used - Bitmasking NOTE - 1. If your states are q0, q1, q2 they will be represented as follows (in the table) q0 = 2^0 = 1 q1 = 2^1 = 2 q2 = 2^2 = 4 2. Similarly union of states will be represented as - q0,q1 = 2^0 + 2^1 = 3 q1, q2 = 2^1 + 2^2 = 6 q0,q1,q2 = 2^0 + 2^1 + 2^2 = 7 3. Do not give any condition for "phi"... That case is not handled... (Coz I m Lazy :P) 4. Follow zero based indexing everywhere 5. Program assumes that if "Number of states are = n", then they are numbered as q0, q1, q2 ... q(n-1) 6. If you find any bug, msg me and forgive me for the errors */ #include #include #include int ninputs; int dfa[100][2][100] = {0}; int state[10000] = {0}; char ch[10], str[1000]; int go[10000][2] = {0}; int arr[10000] = {0}; int main() { int st, fin, in; int f[10]; int i,j=3,s=0,final=0,flag=0,curr1,curr2,k,l; int c; printf("\nFollow the one based indexing\n"); printf("\nEnter the number of states::"); scanf("%d",&st); printf("\nGive state numbers from 0 to %d",st-1); for(i=0;i%d\n",(int)(pow(2,i)),j,stf); if(state[stf]==0) arr[x++] = stf; state[stf] = 1; } } //for new states for(i=0;i\n"); printf("%d-",curr1); for(i=0;i

### bdliya commented Jul 2, 2017

 thanks for the opportunity

### bdliya commented Jul 2, 2017

 is a nice code, its just when I tried running on Turbo c compiler, is reports too many global data file defined, and I don't know what to do

### NandhiniJayakumar commented Mar 11, 2018

 can u please tell a sample input and output for this code

### AyanshMeharwal commented Jan 24, 2019

 try copying the code to code blocks, it will work there