Question: import java.util.ArrayList; public class BinarySearchTree { Node root; public BinarySearchTree ( ) { this.root = null; } public BinarySearchTree ( Node p ) { this.root

import java.util.ArrayList;
public class BinarySearchTree {
Node root;
public BinarySearchTree(){
this.root = null;
}
public BinarySearchTree(Node p){
this.root = p;
}
public boolean isEmpty(){
/**
* check if the tree is empty
* @return true for yes, false for no
*/
}
public boolean isValid(Node start){
/**
* Given a binary tree, check if the tree is a binary search Tree
* @return true for yes, false for no
*/
/**
* if the node element is greater than leftchild and smaller than rightchild,
* recursively check if its leftsubtree and rightsubtree are binary search tree
*/
}
public boolean setRoot(Integer e){
/**
* if tree does not have a root, create root node using e and return true, otherwise, return false
*/
}
public int size(Node start){
/**
* count and return the number of nodes in the tree rooted at start
*/
}
public int depth(Node target){
/**
* count and return the depth of node target
*/
}
public int height(Node start){
/**
* find and return the height of tree or subtree rooted at start
*/
}
public Node parent(Node start, Node target, Node parent){
/**
* Given a tree or subtree rooted at start, find the target node and return its parent
*/
/*recursion
* if target is root, return base case
* if start is null, return null
* if start is target, return parent
* if target element is smaller than start element, find parent on left subtree
* if target element is greater than start element, find parent on right subtree
*
**/
}
public int numChildren(Node target){
/**
* return the number of children for the node referred by target
*/
}
public boolean isInternal(Node target){
/**
* check if a node target is an Internal node, return true for yes, false for No
*/
}
above is the snipet of code that I need help on
 import java.util.ArrayList; public class BinarySearchTree { Node root; public BinarySearchTree(){ this.root

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!