hw2 and study guid

# Introduction to the Theory of Computation

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: Theory of Computation — CSE 105 Context-free Languages Study Guide and Homework 2 Homework 2: Solutions to the following problems should be turned in class on July 21, 1999. Instructions: Write your answers clearly and completely. Please use 8.5 11 inches paper. Use a stapler or a clip to attach the individual pages. Write your name. When presenting any construction, for example, an algorithm or an automaton, please give an overview of the main ideas and then present the construction. Always support the correctness of your construction with a short informal proof. Problems: 1. Show that and , , each is context-free. 2. Let language (CFL). and . Show that 4. Use the pumping lemma to show that the language , each and for some , is not context-free. 1 8 F C§ B X £ A § £0 &Th"g§# Df# e¨dc¢ \$ !   § © §¥ £ a b` £ ` 98 6 5¥ @¨7U2 ` 3. Construct a PDA for the language of all non-palindromes over palindrome over is any string such that . 8 65 ¨7¥ 98 6 5¥ 2 0 @7431§ is a context-free . A ¡ ¢ 8Y§ 9 %¨WUTSQ¨R#PIHG¢ Q X£ 8(6V¥ 2 6 §" Q  §¥ £ 8 1DC§ B A EF § £ 0 ( & \$" ! §   § © §¥ £ )'%# ¨¦¤¢ 876 5 1¥ 9876 5¥ 2 0 @Up§ i and for some Study Guide: 1 Basics of Context-free Grammars To practice writing derivations and parse trees, try problems 2.1 and 2.3 on pages 119/120. 2 Context-free Grammars and Ambiguity The following problems will give you practice in designing context-free grammars. They also cover ambiguity of grammars and normal forms. 1. 2.4, page 120 2. 2.6, page 120 3. 2.8, page 120 4. 2.9, page 120 5. 2.13, page 120 6. 2.14, page 120 7. 2.21, page 122 8. 2.25, page 122 9. 2.26, page 122 10. 2.27, page 122 11. In each case, describe the language generated by the context-free grammar with the productions. (a) (b) (c) (d) u " q 7 q "7 q 5 u "t7 "P5 tyw 7 Px5 "7 "5 w 5 "7 w w 7 tx5 v t7 q 7 C5 q 5 " " 7 P5 t7 q 7 C5 q 5 "" " u t7 q 7 C5 q 5 " " r sq r w r rsqv rsq r sq (e) (f) 12. Find context-free grammars for each of the following languages (a) (b) (c) (d) (e) (f) (g) (h) or or 13. Find a deterministic ﬁnite automaton for the following language generated by a context-free grammar. 14. For each of the following context-free grammars , ﬁnd an equivalent CFG in Chomsky normal form that generates the the language . (a) (b) 3 Pushdown Automata The following problems give you practice in dealing with pushdown automata. 1. Problem 2.5, page 120 2. problem 2.7, page 120 3. Problem 2.10, page 121 4. Problem 2.11, page 121 5. Problem 2.12, page 121 8u   ¥  ¢  7" qqq r x5 C5 " 33sq 8  \$ A 8 \$£ B 8\$ 8\$ 8\$ 8 \$ i 8 A% B  5 B i A " F 7 F 5¥ B8 A " F 7 F 5¥     BA " ! F 7 0 ¥ 5  A £ B " ! F 7 0 ¥ 5 A B X £ " !  F 7 0 ¥ 5  X £ AB " ! F 7 0 ¥  5  A B £ £ A "" ! FF 77 0 ¥¥ ! 05 qq r 5 t7 q " q "7 3rsq " 5 " q "7 q 5 sq  q r 3q sq  u " q q r u " 3q " 3sq 6. Write a pushdown automaton for each of the following languages. (a) The language of all odd-length palindromes over (b) The language of all non-palindromes over (c) The language . and 7. Write a deterministic pushdown automaton for each of the following languages. (a) (b) (c) 4 Closure Operations and Non-context-free Languages 1. Problem 2.2, page 120 2. Problem 2.15, page 121 3. Problem 2.17, page 121 4. Problem 2.18, page 121 5. Show in each case, using the pumping lemma, that the given language is not a CFL (a) (b) (c) 6. Decide in each case whether the language is a CFL. Prove your answer. (a) (b) (c) (d) are the number of ’s and ’s in where respectively.  n§#g l 8 65 71¥ . . 8 " Yg  f§ " I7j'i§Whg feW¥ k8 65¥ 2 V & " § d5 8 65 71¥  n§#g § 7 5 o 8  §nl#g i  n§#g   n§mg {I¦)¨¢  o l "k876 5¥ 2 §¥ £ 8( " "6k8 65¥ 2 6 " §Q§¥ £ %u&W§ II7jTSQp§ x1¨x4¢ 8CQ "G{"§ I6 k 71sTSQp§ tW¨x4¢ " £ " 8 65¥ 2 6 "7Q5§¥ £ 8V & 6 " z7 |5 |7 z5¥ £ x¤sSU} PhhW{x4¢ 8 xV¤&wvgut [email protected]¥ 6 " s5 s q d7 d5 8V & x¤p "g d  7 d ¥ 5 8  n§#D£  n§xmg f¨¥ o g l " § 8  ~} hW{x4¢  £ " |7 z5¥ £ 8x¤wg mWg 7 d 5 ¥ £ V & " d5 d xx4¢ 8 \$  B  y " ! ¨F 7 0 x4¢  5¥ £ , and ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online