Help Badly needed- FSA and ASCII stuff

Discussion in 'C++' started by Willing 2 Learn, Feb 28, 2006.

  1. 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.
     
    Willing 2 Learn, Feb 28, 2006
    #1
    1. Advertising

  2. Willing 2 Learn

    red floyd Guest

    Willing 2 Learn wrote:
    > [do my homework request redacted]


    Show us what you've got so far, and then we'll help. Or make your best
    effort and post your code. You need to put out a minimum of effort
    (beyond typing the specs from your textbook). Once you've got something
    posted, we can look at it and offer advice.
     
    red floyd, Feb 28, 2006
    #2
    1. Advertising

  3. //Attempt for 1
    //Suppose I want to send below
    (01000110+01001101+01001100)*

    int on= 1;
    //int off=0;
    int sent;

    if (sent == 1)
    cout<<"on";
    if(sent == 0)
    cout<<"off";
    if(sent == 10)
    cout<<"stop"

    -------------------------------------------------------------------------------
    //Clueless w/ 2
    --------------------------------------------------------------------------------
    //Attempt for #3

    //Suppose I want to send below
    (01000110+01001101+01001100)*

    int main() {
    char code[8];

    if(code == '01000110' || code== '01001101' || code == '01001100') {
    cout<<"select again or <999> to end"<<endl;
    cin>>code }
    else {
    cout<<"Error! start over"<<endl;

    return 0;
    }
     
    Willing 2 Learn, Feb 28, 2006
    #3
  4. //Attempt for 1
    int on= 1;
    int off = 0;
    int signal;


    for(int i=0 ; i <10; i++) {
    cout<<"Enter signal:<<endl;
    cin>>signal;

    if(signal == 0) {
    cout<<"off"; }
    if(signal == 1) {
    cout<<"on";}
    else {
    if(signal == 01 || signal == 10) {
    cout<<"end"; }

    //Attempt for 2 - Clueless as to how to do this

    //Attempt for 3
    (01000110+01001101+01001100)* // want to generate FML with ASCII
    int main() {
    char num1[8], code[];
    for(int i=0; i<5; i++) {
    cout<<"Enter #";
    cin>>code;
    if(code=='01000110' || code == '01001101' || code == '01001100') {
    cout<<"win" }
    else {
    cout<<"lose"; }
    }
    return 0;
    }
     
    Willing 2 Learn, Feb 28, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Willing 2 Learn
    Replies:
    0
    Views:
    306
    Willing 2 Learn
    Feb 28, 2006
  2. Willing 2 Learn

    Help w/ converting FSA to NFA program

    Willing 2 Learn, Mar 9, 2006, in forum: C++
    Replies:
    1
    Views:
    337
    osmium
    Mar 9, 2006
  3. zam
    Replies:
    19
    Views:
    552
  4. JAVA scipt needed badly

    , Nov 12, 2003, in forum: Javascript
    Replies:
    4
    Views:
    123
    Ivan Marsh
    Nov 13, 2003
  5. Rhugga

    Math::Pari Help Needed, badly.

    Rhugga, Jul 21, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    198
    Sisyphus
    Jul 22, 2005
Loading...

Share This Page