W
Willing 2 Learn
Hey, I'm trying to teach myself C++ and I came across 3 problems. I
understand the concept of FSA but getting the C++ code to do it as
become an issue. Only thing is im clueless as to how to do them; these
are:
1) Devise a coding system to send CAPITAL LETTERS using the ASCII code.
Assume the lights will be ON when you start sending, and use OFF for
ZERO and ON for ONE.
2. I want to use this code to send letters to someone else by switching
the room lights on and off.
3. Write a regular expression and FSA to recognize your code.
HINT given: Consider the following issues:
* How does the received know the difference between a ONE data bit and
the ON normal state of the lights, that is, how does the receiver know
when you START and STOP sending?
* How does the receiver know how long a bit lasts, i.e., how does it
distinguish 1 from 11 from 111 ? In other words, if your code
contains a long string of zeros or ones, could the receiver lose count?
-------------------------------------------------------------------------------------------------------------------------------
2) Write a program for an FSA to recognize the Regular Expression
01(00+11)*10.
-------------------------------------------------------------------------------------------------------------------------------
3) Use C++ to implement a Non-deterministic Finite Automaton to
recognize a string consisting of the 8-bit ASCII codes for JAH
The design program should allow to easily modify the program to
recognize different regular languages, given the regular expression.
Meaning, I should be able to systematically convert ANY regular
expression into the proper tables or pattern of decisions and loops.
IN THE DOCUMENTATION of this program, I have to give the elements of
the NFA:
* alpahbet (0,1),
* states (use numbers),
* start state (use 1 as start state and 0 as the "dead" state)
* list of "accepting" states
* transition rules [number the rules] : state x input -> new state
Operation of program:
1. Input a binary digit 0 or 1, or # to stop.
2. Output the numbers of all states that are currently ON
3. For each ON state, Output all rules that apply to that state and
input,
or NONE, (in form rule number: state number x input -> new state, e.g
1: 1x0->10 ; 2: 1x0->20; 3: 1x0->30
(you need not list rules applying to the dead state)
4. Turn OFF the current states and turn ON the new states
5. Repeat until the last character # has been input
6. Output the list of ON states and the list of ACCEPTING STATES;
if ANY ACCEPTING state is ON, output STRING ACCEPTED,
otherwise, output STRING REJECTED.
Your help would be gladly appreacited with the above; as I thought I
had this stuff covered & now its frustrating me as I can't produce the
results they want.
understand the concept of FSA but getting the C++ code to do it as
become an issue. Only thing is im clueless as to how to do them; these
are:
1) Devise a coding system to send CAPITAL LETTERS using the ASCII code.
Assume the lights will be ON when you start sending, and use OFF for
ZERO and ON for ONE.
2. I want to use this code to send letters to someone else by switching
the room lights on and off.
3. Write a regular expression and FSA to recognize your code.
HINT given: Consider the following issues:
* How does the received know the difference between a ONE data bit and
the ON normal state of the lights, that is, how does the receiver know
when you START and STOP sending?
* How does the receiver know how long a bit lasts, i.e., how does it
distinguish 1 from 11 from 111 ? In other words, if your code
contains a long string of zeros or ones, could the receiver lose count?
-------------------------------------------------------------------------------------------------------------------------------
2) Write a program for an FSA to recognize the Regular Expression
01(00+11)*10.
-------------------------------------------------------------------------------------------------------------------------------
3) Use C++ to implement a Non-deterministic Finite Automaton to
recognize a string consisting of the 8-bit ASCII codes for JAH
The design program should allow to easily modify the program to
recognize different regular languages, given the regular expression.
Meaning, I should be able to systematically convert ANY regular
expression into the proper tables or pattern of decisions and loops.
IN THE DOCUMENTATION of this program, I have to give the elements of
the NFA:
* alpahbet (0,1),
* states (use numbers),
* start state (use 1 as start state and 0 as the "dead" state)
* list of "accepting" states
* transition rules [number the rules] : state x input -> new state
Operation of program:
1. Input a binary digit 0 or 1, or # to stop.
2. Output the numbers of all states that are currently ON
3. For each ON state, Output all rules that apply to that state and
input,
or NONE, (in form rule number: state number x input -> new state, e.g
1: 1x0->10 ; 2: 1x0->20; 3: 1x0->30
(you need not list rules applying to the dead state)
4. Turn OFF the current states and turn ON the new states
5. Repeat until the last character # has been input
6. Output the list of ON states and the list of ACCEPTING STATES;
if ANY ACCEPTING state is ON, output STRING ACCEPTED,
otherwise, output STRING REJECTED.
Your help would be gladly appreacited with the above; as I thought I
had this stuff covered & now its frustrating me as I can't produce the
results they want.