HuffmanCodes

# HuffmanCodes - Author Dave Toth Date This class implements...

This preview shows pages 1–2. Sign up to view the full content.

/** * Author: Dave Toth * Date: November 26, 2005 * * This class implements the Huffman Codes algorithm. It gets its input from * the command line arguments. * * Input: * - n: the number of symbols to consider * - An array S of n positions where S[i] is the ith symbol in S, 1 = i = n. * - An array P of n positions where P[i] is the frequency/probability of the * symbol S[i]. * * Output: * - An array Code of n positions where Code[i] contains the encoding of the * symbol S[i]. * - The average number of bits per letter used by the encoding. * */ public class HuffmanCodes { p /////////////////////////////////////////////////////////////////// // Variables /////////////////////////////////////////////////////////////////// /** * The array that holds the code for each symbol. */ String[] codes; /** * The array that holds the symbols. */ String[] symbols; /** * The array that holds the frequency of how often each symbol occurs. */ float[] frequencies; /////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////// /** * Constructor. Create and instance of the HuffmanCodes class and run it. * @param n - The number of symbols. * @param S - The array of symbols.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

HuffmanCodes - Author Dave Toth Date This class implements...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online