Suppose a sender in a network wanted to communicate the length n of the block it will be using in a subsequent transmission. If there were not limits on the value of n, there would be a problem to simply send the number in binary, since the receiver would find it difficult to know where the end of the number is. Hence we need to encode the integer n using some variable length prefix code, and send the code for n before the code of the length-n block. Design a prefix code for integers and show that an integer n can be encoded with a codeword of length at most log n + O(log log n) – bits.
So I know Huffman’s greedy algorithm for generating prefix codes, but I don’t have any frequencies to build the 2-tree. I was thinking to solve the problem, I would build a tree for 0-9, but I have a feeling I’m way off with that approach. I’m also not quite sure how to show that an integer can be encoded using log n + O(log log n) bits. Any help to get me started would really be appreciated. Thank you for your time!
Asked By : hedgerh
Answered By : Danny
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/32730 Ask a Question Download Related Notes/Documents