473,320 Members | 2,097 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,320 software developers and data experts.

implmenting a DFA that accepts at most 3 a's and any number of b's

I am trying to implement a DFA using C++. the DFA accepts at most 3 a's (can accept only 1 or 2 a's) and any number of b's in between. I am fairly new to C++ so I don't want to program something hard. Anyone has an idea of how to start this of?

one idea is to store any input string in an array and check that string for validity. but the peoblem is I don't understand how do I present the states? Do I represent them as variables? Is there a need to represent them?? am a bit confused.
Feb 18 '11 #1
3 2905
Rabbit
12,516 Expert Mod 8TB
There's many ways to approach it. I would probably use an integer to represent the current state and loop the input while using a switch to determine the new state.
Feb 18 '11 #2
I am sorry, I still do not get how to do this. I was thinking of like if an input is typed in.. I will just count how many a's are there. if it's less or equal to 3 then the grammer is accepted if not then the grammer is rejected. I have an idea but I don't know how to implement it.
Feb 21 '11 #3
Rabbit
12,516 Expert Mod 8TB
That would give you the correct answer but would no longer be a DFA. If you want to take that approach, you just loop through the input and keep a count.
Feb 21 '11 #4

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

Similar topics

4
by: Jeff | last post by:
Hello there, It's possible to check if it's a valid number in <INPUT... I try typeof and parseFloat and it's not working. It's seem impossible to test (with a if) the value "NaN"!! Regards
1
by: Wayne | last post by:
There is probably a simple solution to this but: I have a textbox that is bound to a number field in a table. The field type is "double". If I enter a negative value directly into the table it...
0
by: gwelcom | last post by:
Hi all... I need Stored procedure in db2 which accepts any number of Arguments. The criteria is the various arguements may be integer,varchar,decimal. Regards, Sampath
0
by: wertqt | last post by:
Hi, i have a list of data in access mdb form. If i have a column "Names" and names such as peter, john etc could appear more than once. How can i determine which name appear the most number of...
16
by: globalrev | last post by:
if i want a function that can take any amount of arguments how do i do? lets say i want a function average that accepts any number of integers and returns the average.
58
by: sh.vipin | last post by:
is there any way to find out number of bytes freed on a particular free() call in C
16
by: Peng Yu | last post by:
Hi, I'm wondering if there is a min function (in boost, maybe?) that accepts any number of arguments? std::min only accepts two arguments. If I want to get the minimum number out of many, I have...
0
by: pgharat | last post by:
Hello, I am working on Excel 2007 VBA. I have around 7-8 excel 2007 template in which using VBA added all functionality. In that some of the excel templates i m facing some issue of number...
1
by: BHAGAWATI | last post by:
#include<stdio.h> #include<conio.h> void main() { int r; char g; float p; clrscr(); printf("enter your rollno."); scanf("%d",&r);
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.