Question: public abstract class DupBinaryTree implements DupBinaryTreeADT { / / = = = = = = = = = = = = = = = =
public abstract class DupBinaryTree implements DupBinaryTreeADT
Definition of the DupBinaryTreeNode class
protected class DupBinaryTreeNode
public T info;
public DupBinaryTreeNode lLink;
public DupBinaryTreeNode mLink;
public DupBinaryTreeNode rLink;
pts Default constructor
public DupBinaryTreeNode
this.info null;
this.lLink null;
this.mLink null;
this.rLink null;
pts Alternate constructor
public DupBinaryTreeNodeT item, DupBinaryTreeNode left, DupBinaryTreeNode middle, DupBinaryTreeNode right
this.info item;
this.lLink left;
this.mLink middle;
this.rLink right;
clone method
public Object clone
DupBinaryTreeNode copy null;
try
copy DupBinaryTreeNode super.clone;
catch CloneNotSupportedException e
return null;
return copy;
toString method
public String toString
return info.toString;
End of class DupBinaryTreeNode
Instance variable vor class DupBinaryTree
protected DupBinaryTreeNode root;
Default constructor
public DupBinaryTree
root null;
public Object clone
DupBinaryTree copy null;
try
copy DupBinaryTree super.clone;
catch CloneNotSupportedException e
return null;
if root null
copy.root copyTreeroot;
return copy;
Helper method called by clone
private DupBinaryTreeNode copyTreeDupBinaryTreeNode otherTreeRoot
DupBinaryTreeNode temp;
if otherTreeRoot null
temp null;
else
temp DupBinaryTreeNode otherTreeRoot.clone;
temp.lLink copyTreeotherTreeRootlLink;
temp.mLink copyTreeotherTreeRootmLink;
temp.rLink copyTreeotherTreeRootrLink;
return temp;
Function to print the sorted tree without duplicates values
Input: Nothing
Output: The sorted tree without duplicates values
public void printSortedTreeWithoutDuplicates
printDistinctroot;
TO BE IMPLEMENTED
pts
Function to print the sorted tree without duplicates values
Input: DupBinaryTreeNode t : The current node in the tree
Output: Nothing void
public void printDistinctDupBinaryTreeNode t
Function to print the sorted tree with duplicates values
Input: Nothing
Output: The sorted tree without duplicates values
public void printSortedTreeWithDuplicates
printDuproot;
TO BE IMPLEMENTED
pts
Function to print the sorted tree with duplicates values
Input: DupBinaryTreeNode t : The current node in the tree
Output: Nothing void
public void printDupDupBinaryTreeNode t
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
