Sunday, 15 February 2015

algorithm - Huffman Tree for frequencies of i'th alphabets is 2^i? -


I am ready to test on DS. I read my notes. None of these problems have been created properly. Can I describe it for me?

Looks in a text, I'th is the frequency of the English letter 2 ^ i (^ means the power). What is the height of Huffman tree for these characters?

I need somebody's help ...

height is n - 1 , where n is the size of the alphabet (let's call it h ).

Proof:

  1. The base case n = 2 , the height is one.

  2. Step: 2 ^ n> 2 ^ 0 + ... + 2 ^ (N-1) . Thus, the tree looks for an alphabet of size in this way: There are two children of a root: n -the character (most often one) with a leaf and a tree for the alphabet of size The root of n - 1 means that its height is h (n) = h (n - 1) + 1 = (n - 2) + 1 = n - 1 Is.

I think the height is the number of edges in the longest path of a leaf. If we define the height as many numbers, then the answer is n .


No comments:

Post a Comment