{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Hw6 - Homework 6  CISC 303 Timo Kötzing([email protected]

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Homework 6  CISC 303 Timo Kötzing ([email protected]) Monday, April 5. Friday, April 10. Handed out: Due Date: (8 points) Let A = {a, b}. Give two CFGs accepting L0 and L1 as dened just below, respectively. Problem 1. (i) L0 = {w ∈ A∗ | w = wR } is the set palindromes (words that read the same forwards as backwards). (ii) L1 = {an bk c2n | n, k ≥ 1}. (8 points) Let A = {3, 5, +, ×}, N = {E }. Let P contain all and only the following productions. Problem 2. E → E×E (1) E → E+E (2) E →3 (3) E →5 (4) Let G = (A, N, P, E ). (i) Give ve dierent derivation trees for 3 × 5 + 5 × 3. (ii) For each derivation tree from (i), give the corresponding left-most derivation. (iii) For each derivation tree from (i), give the corresponding right-most derivation. Problem 3. (8 points) Give algorithms dotProductCFG and KleeneStarCFG as follows. (i) dotProductCFG takes two CFGs G0 and G1 and return a CFG G such that L(G ) = L(G0 ) · L(G1 ). (ii) KleeneStarCFG takes a CFG G and return a CFG G such that L(G ) = L(G0 )∗ . Show the result of your algorithm for dotProductCFG on Examples 2.4.2 and 2.4.3 in the Lecture Notes, and show the result of your algorithm for KleeneStarCFG on Example 2.4.2. Note: This last assignment to apply your algorithm is also for you to make sure that your algorithm works; so, please examine the result of your algorithms critically. (8 points) Give an algorithm that takes a CFG G as input and returns a CFG G such that Problem 4. L(G ) = L(G)R . Reminder: For any language L, LR denotes the set of all elements of L reversed: LR = {wR | w ∈ L}. 1 ...
View Full Document

• Spring '08
• Carberry,M
• Context-free grammar, corresponding left-most derivation, corresponding right-most derivation, di1Berent derivation trees

{[ snackBarMessage ]}