473,408 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

CHALLENGE: Implement a DFA

MMcCarthy
14,534 Expert Mod 8TB
This challenge has been inspired by this question which can be found in the C++ forum.

This challenge however is non language specific.

How to implement a DFA ?
Oct 8 '07 #1
5 4541
SammyB
807 Expert 512MB
I need help already: Wikipedia says DFA is a common abbreviation which may refer to any of the following topics [obvious off topic ones are deleted]:
In computing:
  • Data flow analysis
  • Deterministic finite automaton
  • Dual Factor Authentication
  • Design for All (DfA)
In science:
  • Descent from antiquity
  • Direct fluorescent antibody, a medical test
  • Detrended fluctuation analysis
In finance:
  • Dimensional Fund Advisors
  • Dynamic Financial Analysis
In gaming:
  • Death From Above (BattleTech), a jump-jet attack tactic in the BattleTech game universe.
In Statistics:
  • Discriminant Function Analysis
  • Detrended Fluctuation Analysis
In Other Fields:
  • Design for Assembly in engineering
  • Differential Fault Analysis in security
  • Daily Female Appreciation
So, which is it? I vote for Daily Female Appreciation, but that may be too difficult!
Oct 8 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
The general consensus is that this stands for:

Deterministic Finite Automaton
Oct 8 '07 #3
nkg
1
DFA Implementation:-
A DFA can be thought of as a tape which reads one character at a time until end of the tape. Each position on a tape puts DFA in a different state.

Lets consider a simple DFA for parsing a string with even number of 'a's and 'b's in a given word of a grammar.

L = {a,b}
Q={S0,S1,S2,S3)
E={abba, aabb, aaaabb, babaaabb....}

Attached is the state transition diagram for above DFA. Start from state 'S0' and take any input from the grammar. If the automata ends at state 'S0', then the given word is valid for grammar, else invalid input.

I hope from the diagram it is easy to write any simple language steps to implement.
[IMG]C:\Documents and Settings\winxpuser\Desktop\DFA.JPG[/IMG]
Oct 9 '07 #4
r035198x
13,262 8TB
Jos' compiler series available through this index page deals with all the components required here. The tokenizing and parsing parts are most relevant.
The general idea here is to determine the conformance of some input to some well defined language/state. That is part of the job of a compiler.
Oct 18 '07 #5
hdanw
61
Been there, done that.

Also : Discrete Finite Automaton.


The quickest and most straight forward method is to build a 2D array of function pointers.

When you get an event that changes state, you update the current state funtion Pointer to the function indexed by the 2d array.

This is very quick, and works well with windows.

IE : the rows would be one for each state, the columns then are one for each event. The data at that coordinate is the state you change to upon the event.

in your update or message loop you set the function executed to manage that state for each cycle.

FunctionPointerCurrentState();
...
on event
{
FunctionPointerCurrentState = 2dStateTransitionTable[CurrentState][CurrentEvent];
}

I have working code, It Hauls balls, and is ideal for game development, or any other real time applications.

Dan -
Mar 20 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mchoya | last post by:
I'm so frustrated. I'm beginning school next week and I have been working on a simple program for several days now without being able to complete it. (Though I have brushed up on a lot of C++...
8
by: Frank Buss | last post by:
A new challenge: http://www.frank-buss.de/marsrescue/index.html Have fun! Now you can win real prices. -- Frank Buß, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
0
by: Richard Jones | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
0
by: richard | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
11
by: CMM | last post by:
First let me say that maybe I'm having a "duh" moment and perhaps I'm missing something... but it seems to me that no one thing in the System.Collections namespace (even in .NET 2.0) even comes...
78
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that...
13
by: Tomasz Jastrzebski | last post by:
Hello, Below there are two equivalent(?) pieces of C# and VB.Net code. While the C# version compiles with no warning, the VB.Net version does not compile due to the compiler error BC30149: Class...
10
by: brendanmcdonagh | last post by:
Hi all, I'm just getting to grips with java and have set my self a challenge to consolidate my learnings so far as well as implement new learnings. I want to enter a load of possible things to...
80
by: jacob navia | last post by:
Several people in this group argue that standard C is not portable since there are no compilers for it, etc. I propose this program in Standard C, that I have compiled in several OSes to test if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.