Question: JAVA Help!!! Can someone help me code these classes/methods. public class HuffTree implements Comparable { private HuffNode root; /* * Create a default binary tree

JAVA Help!!!

Can someone help me code these classes/methods.

public class HuffTree implements Comparable

{

private HuffNode root;

/*

* Create a default binary tree

*/

public HuffTree()

{

root = null;

}

/*

* Create a tree with two subtrees

*/

public HuffTree (HuffTree t1, HuffTree t2)

{

// add code

}

/*

* Create a tree containing a leaf node

*/

public HuffTree (HuffElement element)

{

// add code

}

/*

* Returns the root of the tree

*/

public HuffNode getRoot()

{

// add code

}

/*

* Compare the roots of the HuffTrees

*/

@Override

public int compareTo (HuffTree ht)

{

// add code

}

// Inner class HuffNode whose element is a HuffElement

public static class HuffNode implements Comparable

{

protected HuffElement element;

public HuffNode left;

public HuffNode right;

/*

* Create a node with passed in element

*/

public HuffNode (HuffElement elem)

{

// add code

}

/*

* Return the element character

*/

public char getChar()

{

// add code

}

/*

* Return the element character count

*/

public int getCount()

{

// add code

}

/*

* Set the element character count

*/

public void setCount (int count)

{

// add code

}

/*

* Return the element character binary code

*/

public String getCode()

{

// add code

}

/*

* Set the element character binary code

*/

public void setCode (String str)

{

// add code

}

/*

* Compare the nodes by comparing the elements

*/

@Override

public int compareTo (HuffNode node)

{

// add code

}

/*

* Return node as a String using the element

*/

@Override

public String toString()

{

// add code

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!