DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help in solving this problem

Hybrid View

  1. #1
    varchala Guest

    Help in solving this problem


    Hi everyone,
    Recently,Started learning c++. Can anyone help me in solving the following
    program:

    consider the language in the alphabet {x,y} defined by the grammar: <S> =
    x<S>x | y<S>y | x | y
    list all the 3-charater strings that are on this language ,also write the
    recursive function that,when passed a character array S, and integers First
    and Last,determines whether S[First..Last]
    is in this language.
    Thank you in advance,
    bye,varchala

  2. #2
    Nickolaus Guest

    Re: Help in solving this problem


    "varchala" <varchala@yahoo.com> wrote:

    >consider the language in the alphabet {x,y} defined by the grammar:

    <S> = x<S>x | y<S>y | x | y
    What does this mean exactly?

    also write the recursive function that,when passed a character array S, and
    integers First
    >and Last,determines whether S[First..Last] is in this language.
    >Thank you in advance,
    >bye,varchala


    here's some psuedo code that may help...

    bool Search ( char s[3], int first, int last )
    {
    bool IsMember = false;

    while ( IsMember == false || stream not ended )
    {
    if ( (s[first] != currentItem[first]) && (s[last] != currentItem[last])
    )
    Search ( char s[3], int first, int last );
    else
    IsMember = true;
    }
    return IsMember;
    }

    I don't know how well this fits to your needs but I hope it helps anyway.
    Good Luck!

    -Nickolaus

  3. #3
    Orrin Guest

    Re: Help in solving this problem


    This isnt a major warning. The default setup is usally fine for simple programs.
    By the time it matters, you'll know what to do.

    O

    "Nickolaus" <watts.77@osu.edu> wrote:
    >
    >"varchala" <varchala@yahoo.com> wrote:
    >
    >>consider the language in the alphabet {x,y} defined by the grammar:

    ><S> = x<S>x | y<S>y | x | y
    >What does this mean exactly?
    >
    >also write the recursive function that,when passed a character array S,

    and
    >integers First
    >>and Last,determines whether S[First..Last] is in this language.
    >>Thank you in advance,
    >>bye,varchala

    >
    >here's some psuedo code that may help...
    >
    >bool Search ( char s[3], int first, int last )
    >{
    > bool IsMember = false;
    >
    > while ( IsMember == false || stream not ended )
    > {
    > if ( (s[first] != currentItem[first]) && (s[last] != currentItem[last])
    >)
    > Search ( char s[3], int first, int last );
    > else
    > IsMember = true;
    > }
    > return IsMember;
    >}
    >
    >I don't know how well this fits to your needs but I hope it helps anyway.
    > Good Luck!
    >
    >-Nickolaus



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center