Question

1. Write grammars for: a. anb2n b. abna :n is multiple of 3 c. an b...

1. Write grammars for:
a. anb2n
b. abna :n is multiple of 3
c. an b an+1
d. C proc def: <type> id ( param_list )
where a param_list is 0 or more declarations of form “<type> id ;”

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

S=> aSbb|\epsilon

The above given grammar will accept all the string which has twice the number of b's compared to number of a's.

Example: abb, aabbbb, aaabbbbbb, aaaabbbbbbbb, aaaaabbbbbbbbbb,... etc.

b)

S=> aSa|b

The string generated by the grammar will start and end with a.

Example: aba. aabaa, aaabaaa, aaaabaaaa, aaaaabaaaaa, ....etc

c)

S=> AbAa

​A=> a

the generated string will starts from a containing one more a than number of a's present before b.

Example: abaa, aabaaa, aaabaaaa, aaaabaaaaa, aaaaabaaaaaa, ....etc.

Add a comment
Know the answer?
Add Answer to:
1. Write grammars for: a. anb2n b. abna :n is multiple of 3 c. an b...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT