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

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

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