Question: Rubric 9 0 points - please implement and complete the six functions. points - 6 functions implemented and stored as a separate commit on GitHub
Rubric
points please implement and complete the six functions. points functions implemented and stored as a separate commit
on GitHub
points Javadoc comments
Description
This assignment will get you familiar with the basic commands of Git, a
version control system. You will need to download Git see Version
Control.pptx for details and install it on your machine. There are a few
simple commands that you need to learn to be able to use Git. The basic
operations can be found in the power slides.
You will implement a few simple operations for a Binary Search Tree.
Download the java file from Canvas labeled TreeDemo.java. In that file
you will find the following methods which need to be implemented :
preOrderTraversalNode root
inOrderTraversalNode root
postOrderTraversalNode root
@ findNode root, int key
@ getMinNode root
@ getMaxNode root
Create a new directory on your machine and initialize as a git repository
by using the git init command. You might want to also set a few global
defaults, refer to the slides for details. Place TreeDemo.java into that
directory and use the git add TreeDemo.java command to stage the file.
After that you can commit it by invoking the git commit m "commit
message" command. You need to implement one function at a time and
make a commit to the repository. Essentially you should have at least
commits to the repository, one after implementing each function.
Once you have implemented all of the functions and everything is up to
date in your working directory, you neeclass 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
