next up previous
Next: Huffman Up: Assignment 11: Huffman Codes Previous: The Frequency table

The HuffTree

Create a class called HuffTree to represent a Huffman Tree as seen on pages 299-301. Here's a suggestion about what the instance variables might be:

public class HuffTree implements Comparable {
  char c;
  int frequency;
  HuffTree left, right;
}

Since HuffTrees implement the Comparable interface, they can be inserted into a Heap, which is useful for assembling the tree.



Allen Downey
Mon Nov 20 11:50:58 EST 2000