answersLogoWhite

0

Algorithm Huffman(X):

Input: String X of length n with d distinct characters

Output: Coding tree for X

Compute the frequency f(c) of each character c of X

Initialize a priority queue Q

for each character c in X do

Create a single-node binary tree T storing c

Insert T into Q with key f(c)

while Q.size() >= 1 do

f1 <- Q.min().key()

T1 <- Q.removein()

f2 <- Q.min().key()

T2 <- Q.removeMin()

Create a new binary tree T with left subtree T1 and right subtree T2

Isert T into Q with f1 + f2

return tree Q.removeMin()

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How can you compress a string efficiently to reduce its size while maintaining its original content?

One way to efficiently compress a string while preserving its content is by using algorithms like Huffman coding or Lempel-Ziv-Welch (LZW) compression. These algorithms analyze the frequency of characters in the string and assign shorter codes to more common characters, reducing the overall size of the string. This compression technique is commonly used in file compression programs like ZIP or gzip.


How can I compress a string of text efficiently?

One way to efficiently compress a string of text is to use algorithms like Huffman coding or Lempel-Ziv-Welch (LZW) compression. These algorithms analyze the frequency of characters in the text and assign shorter codes to more common characters, reducing the overall size of the text while preserving its content.


Why do the people of Umuofia call a snake a string and not a snake at night?

They do not call a snake by name because they are afraid it will hear it's name and respond.


How do you close a string literal?

Just as you have started it. good examples: 'string' "string" `string` &raquo;string&laquo; bad examples: 'string" "string` &raquo;string'


What is a collective noun for string?

The collective noun for 'string' is a ball of string.The noun 'string' is a standard collective noun for:a string of ducksa string of horsesa string of mulesa string of pearlsa string of poniesa string of racehorsesa string of violinists


What are a group of pearls called?

it's a String of Pearls


What is the a-string on a guitar?

The A string is the second string and the second thickest string.


Which string is which on a guitar?

The strings on a guitar are typically numbered from the thinnest string to the thickest string. So, the first string is the thinnest string and the sixth string is the thickest string.


What are the notes to rolling along on the violin?

f on the d string, e on the d string, d on the d string, e on the d string, f on the d string x3, e on the d string x3, f on the d string, a on the a string x2, f on the d string, e on the d string, d on the d string, e on the d string, f on the d string x3, e on the d string x2, f on the d string, e on the d string, d on the d string!! there you go!


The highest string in the cello is the what string?

A string


What are the competitions in The Kite Runner?

In &quot;The Kite Runner,&quot; the main competition is the kite-fighting tournament that takes place in Kabul. Participants fly kites and try to cut down each other's kites using a glass-coated string. The story revolves around the relationship between two friends, Amir and Hassan, and how their bond is tested during the kite-fighting competition.


Why is g string underwear called a g string?

G string may be a gusset string or the string of the thong may be as thin as a g string from the guitar