Ukeoppgaver nr 9 INF2310, våren 2007. This time, the assignments are in English And you will find that Assignment 2 is relevant for later work! Assignment 1: Arithmetic Coding Huffman coding and the like use an integer number (k) of bits for each symbol, hence k is never less than 1. Sometimes, e.g., when sending a 1-bit image, compression becomes impossible. Suppose that the alphabet is X and Y (alias 0 and 1), and that the normalized probability of X is known. Show how you can generate codewords of unequal length for all the possible 2-symbol messages, and find the bit-pattern for each codeword, given that p(X) =2/3. Similarly, map all possible length 3 messages to intervals in the range [0..1], and find the codewords for all possible messages of length 3. How would you encode X Y X X Y X ? Do you get any compression? Is there a relation between the width of the intervals and the number of bits used to encode them? Assignment 2: Implementation of simple Huffman coding Write a java-program that implements Huffman coding of an image, given the normalized histogram. You are NOT expected to implement the actual storage of code words of different lengths. You ARE expected to generate the code words for the pixel values of the image (the code book), so that you can compute the average number of bits per pixel, as well as the entropy. At http://folk.uio.no/inf1040/java/huffman.html you will find a JAVA-program to encode and decode text. This may be useful in order to check that your own implementation produces the proper result.