GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Mar-2004, 10:54
ayoub ayoub is offline
New Member
 
Join Date: Mar 2004
Posts: 4
ayoub is on a distinguished road

C program to convert NFA to DFA


I'm so pleased to write you and I was wondering if you would mind giving me a C Language program that converts NFA to DFA, I have written the algorithm of conversion from NFA to DFA but I couldn't translate it into C language program.
I'm looking forward to getting your answer.
  #2  
Old 08-Mar-2004, 11:04
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi ayoub.

This thread you started is suspiciously like this thread. I would like to keep all replies and responses to the same topic in the same thread if possible.

On to your problem. You say that you have written an algorithm to do this? Is there anyway that you can post it? I am still unclear of what you are asking for, but if you could post an algorithm I will take a look at it.

Thanks.
  #3  
Old 10-Mar-2004, 14:49
ayoub ayoub is offline
New Member
 
Join Date: Mar 2004
Posts: 4
ayoub is on a distinguished road

C program that convert NFA to DFA


Dear sir,
thank you very much for replying to my message,my problem is that i have written an algorihtm to convert non deterministic finite automata to deterministic finite automata but i couldn't translate it to C program and this is the algorithm i have written qx is a state in the NFA and q0 is its start state
QX is a state in the DFA and Q0 is its start state
The eqsilon-closure of a DFA state consists of all the states in the NFA that we can get to with epsilon moves from the states in the DFA state.

Code:
Q0 = { q0 } // but there are some states we can reach from q0 at no cost Q0 = epsilon-closure(Q0) while there are states we haven't processed pick one such state, Qn for each symbol s let tmp be a new, empty, set for each q in Qn add delta(q,s) to tmp end for tmp = epsilon-closure(tmp) if tmp is not in the DFA then let Qi be a new state Qi = tmp add Qi to the DFA else let Qi be the state equivalent to tmp end if add an edge from Qn to Qi in the automaton end for end while for each Qi if there is a q in Qi that is a final state then Qi is a final state end if end for

i was wondering if you would mind giving a C program that convert NFA to DFA.
i'm looking forward to getting your answer
  #4  
Old 07-Mar-2006, 05:16
dipali223 dipali223 is offline
New Member
 
Join Date: Feb 2006
Posts: 1
dipali223 is on a distinguished road

Re: C program to convert NFA to DFA


Please send me program to convert ndfa to dfa.
  #5  
Old 07-Mar-2006, 11:20
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: C program that convert NFA to DFA


Quote:
Originally Posted by ayoub
Dear sir,
written an algorihtm to convert non deterministic finite automata to deterministic finite automata but i couldn't translate it to C program

Here's how I look at a new problem for which I want to write a program:


input==> processing ==> output


What is the input to your program? A representation of some kind of state machine (An NFA, right?)

What is the output? A representation of some kind of state machine (A DFA, right?)

The processing is the algorithm shown in your pseudo-code: convert an NFA to a DFA.


So, to make a program out of words, one thing you have to do is to define how you are going to represent your data objects. Then define and implement the functions that manipulate them in order to perform the defined task.

I would begin by answering the following questions:

Important Question number 1: How will I represent the finite automata?
If this is C++, maybe I will define a class with various member functions and, maybe, overloaded operators If this is C, then I will have some kind of struct probably a linked list of the structs, and various functions that operate on the structs and/or members of the structs. Are there any differences (in detail or structure) between the types of state machines the program is dealing with?

Important Question number 2: What functions are required?
Input? Output? What else is needed to perform the processing of the algorithm?

Important Question number 3: How will I test my program?
Do I have any examples of NFAs that I have already seen the resulting DFAs? Are there any special (problem) machines that might be particularly troublesome.


I will expand a little on number 3, since this is not always among the first things that people think of as they are learning.

In my opinion: It is very important that you have a test plan before you start generating code. You will have to do it sooner or later. I vote for sooner.

As you run through your test cases (manually, or by looking at examples in books), you might form a clearer picture of how the program processing will proceed, and you might get a better idea of how you want to represent the data objects.


Regards,

Dave
  #6  
Old 17-May-2006, 07:28
laith_abed laith_abed is offline
New Member
 
Join Date: May 2006
Posts: 2
laith_abed is on a distinguished road

Re: C program to convert NFA to DFA


Quote:
Originally Posted by ayoub
I'm so pleased to write you and I was wondering if you would mind giving me a C Language program that converts NFA to DFA, I have written the algorithm of conversion from NFA to DFA but I couldn't translate it into C language program.
I'm looking forward to getting your answer.
my e-mail is leth_ebid@yahoo.com
  #7  
Old 17-May-2006, 14:36
laith_abed laith_abed is offline
New Member
 
Join Date: May 2006
Posts: 2
laith_abed is on a distinguished road

C Program Convert Nfa To Dfa


[The next 4 posts belong to a different thread I merged into this one - LuciWiz]

MY E-MAIL LETH_EBID[at]YAHOO[dot]COM PLEASE PLEASE SEND TO ME THE PROGRAM NOW NOW
Last edited by admin : 22-Apr-2007 at 10:15. Reason: Edited email address for anti-spam; !!!Merged thread follows!!!!
  #8  
Old 17-May-2006, 15:48
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: C Program Convert Nfa To Dfa


CPP / C++ / C Code:
#include <stdio.h>

int main()
{
    char inbuf[3];
    char xlate[3];

    printf("Enter NFA: ");
    scanf("%c%c%c", &inbuf[0], &inbuf[1], &inbuf[2]);
    xlate[0] = inbuf[0] - 10;
    xlate[1] = inbuf[1] - 0;
    xlate[2] = inbuf[2] - 0;
    printf("%c%c%c \n", xlate[0], xlate[1], xlate[2]);
    
    return 0;
}
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #9  
Old 18-May-2006, 19:38
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light

Re: C Program Convert Nfa To Dfa


Quote:
Originally Posted by WaltP
CPP / C++ / C Code:
#include <stdio.h>

int main()
{
    char inbuf[3];
    char xlate[3];

    printf("Enter NFA: ");
    scanf("%c%c%c", &inbuf[0], &inbuf[1], &inbuf[2]);
    xlate[0] = inbuf[0] - 10;
    xlate[1] = inbuf[1] - 0;
    xlate[2] = inbuf[2] - 0;
    printf("%c%c%c \n", xlate[0], xlate[1], xlate[2]);
    
    return 0;
}


BRILLIANT!
  #10  
Old 18-May-2006, 20:58
Johnny Johnny is offline
New Member
 
Join Date: May 2006
Posts: 27
Johnny is on a distinguished road

Re: C Program Convert Nfa To Dfa


Quote:
Originally Posted by laith_abed
MY E-MAIL LETH_EBID@YAHOO.COM PLEASE PLEASE SEND TO ME THE PROGRAM NOW NOW


You didn't need to double post. You didn't need to put your email address this is a forum for sharing knowledge ans asking for help. If somebody was to email you the answer nobody else would benefit so don't expect an email anytime soon.

Secondly, if you don't have any code at all, at least post the algorithm you have. The somebody can help you implement it. But asking somebody to write the whole code for you is rude, it means somebody else would have to take the time to do it because you are to lazy to learn how. There is a difference between getting some help and having someone do the work for you. And if that is all you want then you had better try this website http://www.rentacoder.com/

But if it is help you want, I am sure you are at the right place.
 
 

Recent GIDBlogUS Elections and the ?Voter?s Responsibility? by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Will pay money for someone to write a semi complex program bstan Computer Programming Advertisements & Offers 0 23-Feb-2004 04:17
compiling a program within another (C++) Siphiro C++ Forum 5 06-Feb-2004 16:35
error during program rjd72285 C++ Forum 0 11-Nov-2003 19:49
one program access another? dgoulston C++ Forum 1 07-Oct-2003 12:26
convert long to pointer to char realpopeye C++ Forum 2 26-Sep-2003 11:22

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:54.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.