Question: please do the code for the following 6 functions and add the code where it says implement me . class Node { int value; Node
please do the code for the following functions and add the code where it says implement me class Node
int value;
Node left, right;
public Nodeint value
this.value value;
left null;
right null;
class BinarySearchTree
Node root;
recursive insert method
inserts a node into the tree
public void insertint value
tree is empty
ifroot null
root new Nodevalue;
return;
else
Node current root;
Node parent null;
whiletrue
parent current;
ifvalue current.value
current current.left;
ifcurrent null
parent.left new Nodevalue;
return;
else
current current.right;
ifcurrent null
parent.right new Nodevalue;
return;
closing while
closing main ifelse
preorder traversal
Prints the value of every node preorder
public void preOrderTraversalNode root
implement in here
inorder traversal
public void inOrderTraversalNode root
implement in here
postorder traversal
public void postOrderTraversalNode root
implement in here
a method to find the node in the tree
with a specific value
public boolean findNode root, int key
implement in here
a method to find the node in the tree
with a smallest key
public int getMinNode root
implement in here
a method to find the node in the tree
with a largest key
public int getMaxNode root
implement in here
this method will not compile until getMax
is implemented
public Node deleteNode root, int key
ifroot null
return root;
else ifkey root.value
root.left deleterootleft, key;
else ifkey root.value
root.right deleterootright, key;
else
node has been found
ifrootleftnull && root.rightnull
case #: leaf node
root null;
else ifrootright null
case # : only left child
root root.left;
else ifrootleft null
case # : only right child
root root.right;
else
case # : children
root.value getMaxrootleft;
root.left deleterootleft, root.value;
return root;
public class TreeDemo
public static void mainString args
BinarySearchTree t new BinarySearchTree;
tinsert;
tinsert;
tinsert;
tinsert;
tinsert;
tinsert;
System.out.printinorder : ;
tinOrderTraversaltroot;
System.out.println;
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
