0
$\begingroup$

This question is given as an exercise to me . I took a look at the solution given by the instructor which is not the same as my solution .

So I thought it would be wise to ask it here considering I am a newbie on that topic.

My solution basically is as follow :

S -> aSa | bSb | aTb | bTa

T-> aTa | bTb | aTb | bTa | e

My apporach to the problem is as follows : If I don't find any differences (if both characters are the same) , continue with S until you find make a difference then you can do whatever you want with the string as long as you obey the rule of x having the same lenght .

$\endgroup$
0
$\begingroup$

There can be multiple grammars for one language, all equally valid.

We generally don't check solutions to exercises here. The way to tell for yourself whether your answer is correct is to prove it correct: see How to show that L = L(G)? for techniques on how to do that.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.