Recursive Grammer

.
Last edited on
Write the procedure on paper, convert that to a english sentence to describe what your trying to do.
.
Last edited on
Follow your pseudo-code and see if it does indeed produce the desired result.

It's not too difficult to turn pseudo-code into actual code and run it. Try that and see if it gives you the result you want.
For part b, you don't even need code for that. You can check it by hand, but the code you produce should also tell give you the same answer.

Dinomite07 wrote:
{X,Y}, {Z,Y}, {X,Z}, {Z,X}

The definition says
A string in this language must begin with an X
. Do all of those strings begin with an X? Your instructor may want a certain format, but that looks like you're listing subsets. You might want to write it like {XY, ZY, XZ, ZX}. But, of course, be sure to check to make sure all of those strings are actually in the language. Does it say anything about a string beginning with an X and also ending with an X?
I made and follow the code so I think it's right but I am not sure. I know how to use Java but not C++.

How would you write it in Java? Translating Java to C++ isn't that hard - they are syntactically similar up to a point, and certainly similar enough for the methods you'd use for this problem.

Many of us here can also understand Java. Go ahead and show us what you'd write in Java and we can help you go from there.
Are there any guides/tutroials for recursive grammar I can study? I can't seem to find any.
Topic archived. No new replies allowed.