Question

Q6: (15 points) Give context-free grammar that generate the following language. a) abick ij,k 20 and i 2j +k} b) {w E 0,1 |

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

a) { aibjck | i, j, k ≥ 0 and i = 2j + k }

The language contains strings like: ε, ac, aab, aacc, aaabc, aaaccc, aaaabcc, ...


The context free grammar shown below can generate the above language.

S --> aSc / aAc / A / ε

A --> aaAb / aab / ε

For example, consider generating the word aaaabcc.

S aSc aaAcc ааaaAbcc aaaabcc

b)

{w ∈ {0, 1}* | the length of w is even, started by 1 and ended 01}

The language contains strings like 1001, 1101, 100001, 100101, 101001, 101101, 110001, ...

Clearly, every string in this language must start with 1 and end with 01.

So,

S --> 1A01

Here, the length of the string must be an even number. The length of prefix(1) + suffix(01) is odd. So, the middle term must be a string with odd number length. So,

A --> 0T / 1T

T --> 0A / 1A / ε

S --> 1A01

A --> 0T / 1T

T --> 0A / 1A / ε

For example, consider generating the string 1010 01

S 1A01 10T01 101A01 1010T0 101001

This way, we can generate CFG's for languages.

Hope you understood the answer. Please consider commenting if you don't understand anything.

Add a comment
Know the answer?
Add Answer to:
Q6: (15 points) Give context-free grammar that generate the following language. a) abick ij,k 20 and...
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