Problem 1 (4 points) Find context-free grammar for the following language (with $n \ge 0$ and $m \ge 0$): $L = \{w \in \{a, b\}^* : n_a \ne n_b\}$ Answer:
Added by Javier D.
Close
Step 1
This means that the number of occurrences of the letter 'a' in a string should be equal to the number of occurrences of the letter 'b'. To ensure this condition, we can start by generating an equal number of 'a' and 'b' in the string. We can do this by Show more…
Show all steps
Your feedback will help us improve your experience
Maanya Naveen and 55 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
Select the correct alternative from the given choices. Consider the following languages $L_{1}, L_{2}$ and $L_{3}$ : $L_{1}=\left\{a^{n} b^{m} c^{n+m} \mid n, m \geq 0\right\}$ $L_{2}=\left\{a^{n} b^{n+1} c^{n+2} \mid n \geq 0\right\}$ $L_{3}=\left\{a^{n} b^{n} c^{m} \mid n, m \geq 0\right\}$ Which of following statement is true? (A) $L_{1}, L_{2}, L_{3}$ are context free languages (B) $L_{1}, L_{2}$ are context free but not $L_{3}$ (C) $L_{1}, L_{3}$ are context free but $\operatorname{not} L_{2}$ (D) $L_{1}, L_{2}, L_{3}$ are not context free languages.
Theory of Computation
CONTEXT FREE LANGUAGES AND PUSH DOWN AUTOMATA
Select the correct alternative from the given choices. Let the language $L_{1}, L_{2}$ are defined as: $L_{1}:\left\{a^{i} b^{2 i} c^{j} \mid i, j \geq 0\right\}, L_{2}=\left\{a^{i} b^{2 i} a^{i} \mid i \geq 0\right\} .$ Which of following is true? (A) $L_{1}, L_{2}$ are context free (B) Only $L_{1}$ is context free (C) Only $L_{2}$ is context free (D) Neither $L_{1}$ nor $L_{2}$ is context free
Problem 5. (20 points) A regular grammar is a grammar G = (V,T,S,P) in which production rules are of the form A → a or A → aB, where a ∈ T and A, B ∈ V. The rule S → λ is allowed, where S is the start variable. Regular grammars generate regular languages. Give a regular grammar for the following regular languages: L1 = L(a*b* + (a + b)(a + b)) L2 = {w ∈ {a, b}* : |w| = 3k, for some k ≥ 0}
Madhur L.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD