Question: Did I do this correctly? Question: Construct context-free grammars that generate the following languages (give your answers as a set of rules): {a n b

Did I do this correctly?

Question:

Construct context-free grammars that generate the following languages (give your answers as a set of rules):

  1. {anbn+kak{a,b}|n0,k0}

Answer:

S | aAbB | AbBa

A | aAb

B | bBa

Possible strings to test on:

n = 0, k = 2

bbaa

SAbBabBabbBaabbaabbaa

n =2, k = 1

aabbba

SaAbBaaAbbBaabbbBaaabbbaaabbba

n = 1, k = 3

abbbbaaa

SaAbBabBabbBaabbbBaaabbbbBaaaabbbbaaaabbbbaaa

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!