Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions