HM7-Grammars-ParseTrees-Ambiguity

# HM7-Grammars-ParseTrees-Ambiguity - L G Which one 5 Using...

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

CS 341 Automata Theory Elaine Rich Homework 7 Due: Thursday, March 1, 2007 This assignment covers Sections 11.1 - 11.6. 1) Let Σ = { a , b }. For the languages that are defined by each of the following grammars, do each of the following: i . List five strings that are in L . ii . List five strings that are not in L . iii . Describe L concisely. You can use regular expressions, expressions using variables (e.g., a n b n , or set theoretic expressions (e.g., { x : …}) iv . Indicate whether or not L is regular. Prove your answer. a) S a S | S b | ε b) S a S a | b S b | a | b c) S a S | b S | ε d) S a S | a S b S | ε 2) Consider the following grammar G : S 0 S 1 | SS | 10 . Show a parse tree produced by G for each of the following strings: a) 010110 b) 00101101 3) Let G be the grammar of Example 11.12. Show a third parse tree that G can produce for the string (())(). 4) Consider the following context free grammar G : S a S a S T S ε T b T T c T T ε One of these rules is redundant and could be removed without altering
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: L ( G ). Which one? 5) Using the simple English grammar that we showed in Example 11.6, show two parse trees for each of the following sentences. In each case, indicate which parse tree almost certainly corresponds to the intended meaning of the sentence: a) The bear shot Fluffy with the rifle . b) Fluffy likes the girl with the chocolate . 6) Show a context-free grammar for each of the following languages L : a) { a i b j : 2 i = 3 j + 1}. b) { w ∈ { a , b }* : # a ( w ) = 2 # b ( w )}. c) { w ∈ { a , b }* : w = w R }. d) { w ∈ { a , b }* : every prefix of w has at least as many a ’s as b ’s}. e) { a m b n c p d q : m , n , p , q ≥ 0 and m + n = p + q }. f) { b i # b i +1 R : b i is the binary representation of some integer i , i ≥ 0, without leading zeros}. (For example 101#011 ∈ L .)...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online