2. Find a CFG for the following languages a. L={WWR, W={a,b}*} b. L={a<sup>n</sup>b<sup>m</sup>, n+m is even}
Added by Melissa H.
Close
Step 1
To find a CFG for the language L={WWR, W={a,b}*}, we can break it down into smaller parts. First, let's consider the production rules for generating W. Since W can be any string of a's and b's, we can have the following production rules: S -> aS | bS | ε This Show more…
Show all steps
Your feedback will help us improve your experience
Patricia Holmes and 98 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Give a CFG that generates the language L(a*b*c*) { anbncn | n is a non-negative integer }. This question is quite challenging; you will first need to devise a good strategy for how the CFG should work and then create the CFG to implement the strategy. You might want to do the other questions first. No messy writing please.
Supreeta N.
1. Give a CFG for each of the following languages (with n, m, k ≥ 0.) Note: You only need to give production rules for each grammar. (a) L = {a^n b^2n | n ≥ 2} (b) L = {w ∈ {a, b}* | na(w) = 3nb(w)}. (c) L = {wwR | w ∈ {a, b}*} (d) L = {w ∈ {a, b}* | w = wR, that is, w is a palindrome. } (e) L = {a^n b^m | n ≥ m + 3}. (f) L = {a^n b^m | n < m + 3}. (g) L = {a^m b^n c^k | m = n + k}. (h) L = {a^m b^n c^k | n = k + m}. (i) L = {a^m b^n c^k | n = m + 2k}. (j) L = {w ∈ {a, b, c}* | na(w) + 2nb(w) ≠ nc(w)}. (k) L = {a^m b^n c^k | m > n or n + m = k}.
Sri K.
Describe the languages that the following CFGs generate: a) S → aX X → aX | bX | ε b) S → XaXaX X → aX | bX | ε c) S → SS | XXX X → aX | Xa | b Explain the steps, please.
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD