in Algorithms
137 views
1 vote
1 vote

From huffmann encoding how will we find max and min number of comparisons? 

what will be the max and min comparisons here

in Algorithms
by
137 views

3 Comments

well i think we can do this way but i  havent used any formula regarding huffman code

it is like merging the files,,if you have lower no. of element in the leafs then there will be less number of comparisons because you are doing comparisons equal to height of the tree,

as we know no of comparisons for two groups of element having n and m element are n+m-1

so at each merging point we have given the sum of below nodes so just minus one from each node and add them so you will get 219 comparisons it is minimum and for max just interchange the node of higher weights to lower leaf =362 comparisons
1
1
@red

i understood the minimum ......

Can u explain max in a bit more detailed way
0
0
Well how can you get a max number of comparisons?? only if you include the higher weights(sort them in decresing order) maximum numbers of time in calculations and this is posible only when you use them in leaf nodes.
0
0

Please log in or register to answer this question.