Question: complete this large binary tree please: import java.util.Iterator; import com.google.gson. * ; / / for cloning import com.google.gson.reflect.TypeToken; / / for cloning import java.lang.reflect.Type; /
complete this large binary tree please:
import java.util.Iterator;
import com.google.gson.; for cloning
import com.google.gson.reflect.TypeToken; for cloning
import java.lang.reflect.Type; for cloning
public class BinarySearchTree extends BinaryTree implements Iterable
Node deepCopyNodeNode copyMe
if null copyMe
return null;
Node rv new Node;
Gson gson new Gson;
Type typeOfT new TypeTokengetType;
rvdata gson.fromJsongsontoJsoncopyMedata typeOfT;
rvleftChild deepCopyNodecopyMeleftChild;
if null rvleftChild
rvleftChild.parent rv;
rvrightChild deepCopyNodecopyMerightChild;
if null rvrightChild
rvrightChild.parent rv;
return rv;
public BinarySearchTreeBinarySearchTree copyMe
verbose copyMe.verbose;
if verbose
System.err.printlnCopying this tree: copyMe;
root deepCopyNodecopyMeroot;
public BinarySearchTree
root null;
verbose false;
public void cloneBinarySearchTree copyMe
root deepCopyNodecopyMeroot;
public Iterator iterator
Iterator iterRv new Iterator
@Override
public boolean hasNext
return false;
hasNext
@Override
public T next
return null;
next
iterator remove not supported
@Override
public void remove
throw new UnsupportedOperationException;
remove
; anon inner class iterator
return iterRv;
public boolean equalsBinarySearchTree other
if verbose
System.err.printlnComparing:tTree:
toString;
System.err.printlnWith:tTree:
other;
if they are the same object, return true. Nothing to do
if this other
return true;
return false;
public int hashCode
int rv ;
Iterator meIter iterator;
while meIterhasNext
T meValue meIter.next;
no exception on overflow, so this is fine
rv meValue.hashCode;
We can add a positional element order but not a structural one
return rv;
public boolean insertT addMe
return false;
public boolean removeT removeMe
return false;
public boolean searchT findMe
Node current root;
while null current && current.data.equalsfindMe
current findMecompareTocurrentdata current.leftChild : current.rightChild;
return null current;
hi can you please implement all the funtions such as insert and delete?
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
