(1) Give the language, L(G), in a formal expression, including the relational operator in the length of strings. e.g.) L(G) = {w| #(a) < #(b) in w} { w| #(a) = #(b) = #(c) in w } (3) [5] Give a derivation for 01011010 using the grammar in (2)
Added by Lee C.
Step 1
Since the grammar is not provided, I will assume a simple context-free grammar for the sake of this example. Let's define a grammar \( G \) that generates binary strings with equal numbers of 0s and 1s. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 69 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
Find a grammar for the language L = {a^n b^(2n+1) c^(3n-1) | 0 < n} (a) Give the grammar G. (b) Document the productions and the nonterminals of G. (c) Derive several representative strings with the grammar. (d) Prove by induction that for all w such that S ⇒G w the following relation between the number of a's and the number of c's holds: 3 × #a(w) + 1 = #c(w) (e) Where is the language L(G) in the Chomsky hierarchy? (The best answer is the most descriptive answer.)
Akash M.
1. Write derivations for four strings of various lengths and describe what is the language generated, L(G) by the following grammar G. V = {S, A, B} T = {a, b}, P = S -> A, S -> B, B -> bB, A -> aA, A -> λ, B -> λ S is the start nonterminal
Adi S.
Q 8. Consider the context-free grammar G with terminal symbols T = {x, y, e, -1, (, )}, non-terminal symbols N = {σ, F, B}, starting symbol σ, and production rules σ → Fσ | F F → B | B-1 B → x | y | e | (Fσ) Note that we are regarding -1 as a single symbol. The string B-1, for example, has length 2; it is the symbol B followed by the symbol -1. (a) Give leftmost derivations in G for each of the following strings. (i) e-1 (ii) y-1x-1 (iii) xyx-1y-1 (b) Use the method of Lecture 8B to draw the transition diagram of a PDA accepting the language generated by G. State the input alphabet and the stack alphabet of your PDA. (c) Show how your PDA in (b) accepts the string y-1x-1. Your answer to (a)(ii) will be useful.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD