| | |
Translate an algorithm to C program
![]() |
•
•
Join Date: Mar 2004
Posts: 3
Reputation:
Solved Threads: 0
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.
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 helping me to translate it to a C program that convert NFA to DFA.
i'm looking forward to getting your answer
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.
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 helping me to translate it to a C program that convert NFA to DFA.
i'm looking forward to getting your answer
is that the psuedo code you want to translate? or is that VB, sorry some times I can't tell the diffrence becuase I'm not well educated about VB.
If its VB you can try posting it in the VB section as well, I bet alot of C programmers who also know VB stop by there.
If its VB you can try posting it in the VB section as well, I bet alot of C programmers who also know VB stop by there.
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
![]() |
Similar Threads
- Time complexity of algorithm (Computer Science)
- Need help writing an algorithm for this program (C++)
- Round Robin Algorithm Simulation (C++)
- Round Robin Algorithm Simulation (C++)
- correct errors in this program (C)
- regarding round robin algorithm (C++)
Other Threads in the C Forum
- Previous Thread: ?'s, JPG, Free Store and Compiler Synthesis
- Next Thread: Library compatibility problem?
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. lowest match matrix microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h windowsapi





