- #1
sabrina123456
- 2
- 0
I am sabrina, year 10 at school. I have question of how to write Context free grammar >
The set of all strings beginning with a string of occurrences of the first letter specified above, and ending with a string of occurrences
of the second letter specified above. In the middle is a string of the character
c. If the number of occurrence of the first letter is n and the number of
occurrence of the second letter is m, then the number of occurrences of c is x.n
+ y.m + 1.
For example, the language is a^n c^x.n + y.m + 1b^m, with x=2, y=3,
and includes accccccbb and aacccccb.
And this is what I actually wrote below to write the context free grammar:
S -> ABC
A - > Aa
A - > a
B - > Bb
A - > b
C - > c
is this correct? Please I need help and i am trying to learn my best. Thank you for your help.
Regards
Sabrina
The set of all strings beginning with a string of occurrences of the first letter specified above, and ending with a string of occurrences
of the second letter specified above. In the middle is a string of the character
c. If the number of occurrence of the first letter is n and the number of
occurrence of the second letter is m, then the number of occurrences of c is x.n
+ y.m + 1.
For example, the language is a^n c^x.n + y.m + 1b^m, with x=2, y=3,
and includes accccccbb and aacccccb.
And this is what I actually wrote below to write the context free grammar:
S -> ABC
A - > Aa
A - > a
B - > Bb
A - > b
C - > c
is this correct? Please I need help and i am trying to learn my best. Thank you for your help.
Regards
Sabrina