The Artima Developer Community
Sponsored Link

Java Answers Forum
Huffman Tree

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jaded

Posts: 2
Nickname: jaded
Registered: Mar, 2003

Huffman Tree Posted: Mar 23, 2003 7:37 PM
Reply to this message Reply
Advertisement
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];
  }

Topic: Composite pattern Previous Topic   Next Topic Topic: new machine

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use