CS 141 Homework Assignment #3 Set Feb. 25, 2008 Due March 10, 2008, before class 1. [15 pts] [Levitin, p. 203] Question 8. (The same question is also in the 1st edition of Levitin, Question 8, pp. 198-199.) Hint: Some hints are given in the book. For part b, pick any point as the radiant and sort the rest of the points by the angles of the rays from the radiant to them. Be careful with ordering the points that lie on the first and last rays. 2. [15 pts] [Levitin, p. 222] Question 4. (The same question is also in the 1st edition of Levitin, Question 4, p. 217.) 3. [10 pts] [Levitin, p. 292] Question 7 (or page 288 of the 1st edition of Levitin). You should illustrate your answer in a style similar to Figure 8.7 on page 291 (or page 287 on the 1st edition of Levitin). 4. [10 pts] Let a, b, c, d, e, f, and g be 7 letters that appear with probabilities 0.2, 0.01, 0.05, 0.04, 0.3, 0.3, and 0.1 respectively. Construct an optimal Huffman code (and trie) step by step, and calculate the average code length. 5. [10 pts] [Levitin, p. 327] Question 2(a) (or page 323 of the 1st edition of Levitin). You should illustrate your answer in a style similar to Figure 9.10 on page 325 (or page 321 of the 1st edition of Levitin). 6. [10 pts] Compute the prefix function pi for the pattern abaabab and show the comparisons made by the KMP algorithm on the pattern and text ababaabaababababaabab, using a diagram similar to the one in http://www.cs.ucr.edu/~jiang/cs141/kmp-example-03.doc 7. [Optional, 10 bonus pts] [Levitin, p. 314] Question 10. (The same question is also given in the 1st edition of Levitin, Question 9, p. 311.)