huffman code

how to start to build tree

its heap but how to build a correct tree

IMG_20141013_075237.jpg

Responses

vivek14's picture

A =10, E=15 , I=12 , S=3 , T=4, P=13, N=1

The Huffman coding says that

1)Choose 2 minimum values, add them and put in parent node of both.

2) Place smaller values at left.

first the set is given above, we choose 2 smallest values ie 1 and 3 , add them and put in parent. So parent 4, left N and right S.

Put this 4 again in the set and now again choose 2 minimum from set which result in minimum sum at next parent. Now these are 4 and 4. You can arrange in any order in similar weight case.

Next case will be 8 and 10 so you have to put 8 at left and 10 at right.

Your 1st tree is correct except 10 will be at right to 8.

Did not found what you are looking for, Ask your doubt or Help by your contribution

Enter your search keyword:

Search form

Wait!

Here is a chance to join biggest community of technical Students,
Tutors with FREE learning resources and so much more.
It takes less then 60 seconds.