Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago