Jaded
Posts: 2
Nickname: jaded
Registered: Mar, 2003
|
|
Huffman Tree
|
Posted: Mar 23, 2003 7:37 PM
|
|
Please help me construct a huffman tree. I'm trying to write code that will read from file letters and their frequencies. then i'll sort them. and then put them into the tree. i have already taken care of reading from file and sorting, i'm just lost at the method that will construct the tree. any help will be appreciated. thanks. here is my method so far...
public void HuffmanTree(Huffman theArray[], int i){
Huffman theNode[] = new Huffman[60];
String letters = theArray[i].letter + theArray[i+1].letter;
int numbers = theArray[i].freqs + theArray[i+1].freqs;
theNode[i] = new Huffman(letters,numbers);
theNode[i].left = theArray[i];
theNode[i].right = theArray[i+1];
}
|
|