Huffman coding and Golomb-Rice codes

Q1) Consider the tree at page 44 in the lecture slides

The symbols are denoted s_1 = 'a',s_2 = 'b',...,s_8 = 'h' What are the probabilities of the 8 symbols for which the tree is optimal? (Hint: we know that ideal codelengths are l_i = -log_2 p_i) What is the average codelength of the code?

Q2) Take k to be your student number ( e.g., k=123456 ).

What is the codelength when encoding k by a Golom-Rice code with parameter l=2^r, where r =0,1,2,..., 31? Pick the best value of r and write down the GR codeword of your student number, k.

Q3) Consider the table with the student numbers of registered students to this lecture

(listed below in variable A). a) What is the codelength for encoding all numbers from A by a GR code, say with parameter l=2^r and r=10? b) Which is the best value of r for encoding A, and what number of bits per student number is obtained in the best case? Propose a revertible transformation of A, so that the resulting codelength is smaller. You can change the order of the students or do simple operations that allow recovery of all student numbers, in whatever order. Hint: remember that GR is an optimal code for exponentially decaying distributions on symbols.

```A =[177031
218141
270723
238856
224062
263601
256276
270212
270212
198511
263600
267926
182522
247820
263023
267923
244914
267924
233522
270743
270551
165091
229670
270525
233588
270742
233961
239872
267639
270735
256292
243351
229339
233779
246845
238739
270715
256252
270744
168712
270523
270736
256309]
```
```A =

177031
218141
270723
238856
224062
263601
256276
270212
270212
198511
263600
267926
182522
247820
263023
267923
244914
267924
233522
270743
270551
165091
229670
270525
233588
270742
233961
239872
267639
270735
256292
243351
229339
233779
246845
238739
270715
256252
270744
168712
270523
270736
256309

```