SlideShare a Scribd company logo
Required to augment the author's Binary Search Tree (BST)
code to support these new operations. Method names below are
merely suggestions. (The author’s class is attached separately in
the file called “authordoc”. I just built a simple test tree in the
author’s main method which can be used to test the various
operations. )
1. AnyType nthElement(int n) -- returns the n-th element
(starting from 1) of the in-order traversal of the BST.
2. int rank( AnyType x ) -- returns the "rank" of x. The rank of
an element is its position (starting with 1) in an in-order
traversal.
3. AnyType median( ) -- returns the median (middle) element in
the BST. If the BST contains an even number of elements,
returns the smaller of the two medians.
4. boolean isPerfect( ) -- returns true if the BST is a perfect
binary tree.
5. boolean isComplete( ) -- returns true if the BST is a complete
binary tree.
6. String toString( int nrLevels ) -- generates the level-order
output described in the sample output below.
Most of these operations could easily be implemented by
performing an in-order traversal inside the BST and perhaps
placing the results in an ArrayList. However, such a method is
extremely inefficient. Instead, we are going to achieve faster
performance by "augmenting" the BST nodes. You will add a
new private integer data member ("tree size") to the BinaryNode
which stores the size of the tree rooted at that node (including
the root). You must develop your own algorithms for these
operations, but obviously you will use the new tree size data
member to guide your search. Think before you code and think
recursively!
These items cover those topics not addressed elsewhere in the
project description. (R) indicates a requirement, (H) indicates a
hint, and (N) indicates a note.
1. (R) Although we are only using the BST for integers, the BST
must remain a generic class.
2. (R) Duplicate values are not allowed. Attempts to insert a
duplicate value should be ignored.
3. (R) Attempts to remove non-existent values should be
ignored.
4. (R) From a coding perspective, the easiest way to avoid
duplicate insertions or attempting to remove non-existent
elements is to first call find( ). However, this technique is NOT
permitted for two reasons.
Calling find( ) before each insert/remove doubles the running
time for these operations and is therefore inefficient.
Recusively coding the insert/remove methods to handle these
situations is a great learning experience.
5. (R) The level order print (PRINT command) outputs the
value of each node, the size of the tree rooted at that node, and
the value of the node's parent in that order, inside parenthesis,
separated by commas. (node value, tree size, parent value).
Since the root has no parent, print NULL for the root's parent
value. For readability, separate the levels with a blank line and
print no more than 6 node/size/parent values per line. If a level
requires multiple lines, use consecutive lines (without a blank
line between them).
6. (R) Efficieny counts! Use the most efficient algorithm
possible In particular, don't make multiple searches in the tree
when one will do. (Yes, we know it doesn't matter from an
asymptotic analysis point of view.)
7. (H) Almost all of these operations should be written
recursively, but not necessarily all of them.
8. (N) As is customary, your BST class should not provide any
methods for printing. However, the BST can provide a method
that formats a string containing information that the user wishes
to print. Overloading the toString( ) method is a common
technique to achieve this kind of functionality.
Note: The instructor noted that once the tree is built, it will not
be changed during testing of the program. (just to simplify the
task if that helps)
package Ast.rt;
import java.util.ArrayList;
// BinarySearchTree class
//
// CONSTRUCTION: with no initializer
//
// ******************PUBLIC
OPERATIONS*********************
// void insert( x ) --> Insert x
// void remove( x ) --> Remove x
// boolean contains( x ) --> Return true if x is present
// Comparable findMin( ) --> Return smallest item
// Comparable findMax( ) --> Return largest item
// boolean isEmpty( ) --> Return true if empty; else false
// void makeEmpty( ) --> Remove all items
// void printTree( ) --> Print tree in sorted order
//
******************ERRORS***************************
*****
// Throws UnderflowException as appropriate
/**
* Implements an unbalanced binary search tree.
* Note that all "matching" is based on the compareTo method.
* @author Mark Allen Weiss
*/
public class BinarySearchTree<AnyType extends Comparable<?
super AnyType>>
{
/**
* Construct the tree.
*/
public BinarySearchTree( )
{
root = null;
}
/**
* Insert into the tree; duplicates are ignored.
* @param x the item to insert.
*/
public void insert( AnyType x )
{
root = insert( x, root );
}
/**
* Remove from the tree. Nothing is done if x is not found.
* @param x the item to remove.
*/
public void remove( AnyType x )
{
root = remove( x, root );
}
/**
* Find the smallest item in the tree.
* @return smallest item or null if empty.
* @throws Exception
*/
public AnyType findMin( ) throws Exception
{
if( isEmpty( ) )
throw new Exception( );
return findMin( root ).element;
}
/**
* Find the largest item in the tree.
* @return the largest item of null if empty.
* @throws Exception
*/
public AnyType findMax( ) throws Exception
{
if( isEmpty( ) )
throw new Exception( );
return findMax( root ).element;
}
/**
* Find an item in the tree.
* @param x the item to search for.
* @return true if not found.
*/
public boolean contains( AnyType x )
{
return contains( x, root );
}
/**
* Make the tree logically empty.
*/
public void makeEmpty( )
{
root = null;
}
/**
* Test if the tree is logically empty.
* @return true if empty, false otherwise.
*/
public boolean isEmpty( )
{
return root == null;
}
/**
* Print the tree contents in sorted order.
*/
public void printTree( )
{
if( isEmpty( ) )
System.out.println( "Empty tree" );
else
printTree( root );
}
/**
* Internal method to insert into a subtree.
* @param x the item to insert.
* @param t the node that roots the subtree.
* @return the new root of the subtree.
*/
private BinaryNode<AnyType> insert( AnyType x,
BinaryNode<AnyType> t )
{
if( t == null )
return new BinaryNode<AnyType>( x, null, null);
int compareResult = x.compareTo( t.element );
if( compareResult < 0 ){
t.left = insert( x, t.left );
}
else if( compareResult > 0 ){
t.right = insert( x, t.right );
}
else
; // Duplicate; do nothing
return t;
}
/**
* Internal method to remove from a subtree.
* @param x the item to remove.
* @param t the node that roots the subtree.
* @return the new root of the subtree.
*/
private BinaryNode<AnyType> remove( AnyType x,
BinaryNode<AnyType> t )
{
if( t == null )
return t; // Item not found; do nothing
int compareResult = x.compareTo( t.element );
if( compareResult < 0 )
t.left = remove( x, t.left );
else if( compareResult > 0 )
t.right = remove( x, t.right );
else if( t.left != null && t.right != null ) // Two children
{
t.element = findMin( t.right ).element;
t.right = remove( t.element, t.right );
}
else
t = ( t.left != null ) ? t.left : t.right;
return t;
}
/**
* Internal method to find the smallest item in a subtree.
* @param t the node that roots the subtree.
* @return node containing the smallest item.
*/
private BinaryNode<AnyType> findMin(
BinaryNode<AnyType> t )
{
if( t == null )
return null;
else if( t.left == null )
return t;
return findMin( t.left );
}
/**
* Internal method to find the largest item in a subtree.
* @param t the node that roots the subtree.
* @return node containing the largest item.
*/
private BinaryNode<AnyType> findMax(
BinaryNode<AnyType> t )
{
if( t != null )
while( t.right != null )
t = t.right;
return t;
}
/**
* Internal method to find an item in a subtree.
* @param x is item to search for.
* @param t the node that roots the subtree.
* @return node containing the matched item.
*/
private boolean contains( AnyType x,
BinaryNode<AnyType> t )
{
if( t == null )
return false;
int compareResult = x.compareTo( t.element );
if( compareResult < 0 )
return contains( x, t.left );
else if( compareResult > 0 )
return contains( x, t.right );
else
return true; // Match
}
/**
* Internal method to print a subtree in sorted order.
* @param t the node that roots the subtree.
*/
private void printTree( BinaryNode<AnyType> t )
{
if( t != null )
{
printTree( t.left );
System.out.println( t.element );
printTree( t.right );
}
}
/**
* Internal method to compute height of a subtree.
* @param t the node that roots the subtree.
*/
private int height( BinaryNode<AnyType> t )
{
if( t == null )
return -1;
else
return 1 + Math.max( height( t.left ), height( t.right ) );
}
// Basic node stored in unbalanced binary search trees
private static class BinaryNode<AnyType>
{
// Constructors
BinaryNode( AnyType theElement )
{
this( theElement, null, null);
}
BinaryNode( AnyType theElement,
BinaryNode<AnyType> lt, BinaryNode<AnyType> rt)
{
element = theElement;
left = lt;
right = rt;
}
AnyType element; // The data in the node
BinaryNode<AnyType> left; // Left child
BinaryNode<AnyType> right; // Right child
int treeSize;
}
/** The tree root. */
private BinaryNode<AnyType> root;
// Test program
public static void main( String [ ] args ) throws Exception
{
BinarySearchTree<Integer> t = new
BinarySearchTree<Integer>( );
int[] nums = new int[] {55, 40, 60, 30, 45, 70, 20, 35, 44,
47, 66, 80, 3, 36, 37, 43, 48, 65, 67, 77, 90};
for(int i = 0; i < nums.length; i++)
t.insert(nums[i]);
t.printTree();
System.out.println( "Checking... (no more output means
success)" );
}
}

More Related Content

Similar to Required to augment the authors Binary Search Tree (BST) code to .docx

Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdf
hardjasonoco14599
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
Running Head Discussion Board .docx
Running Head Discussion Board                                  .docxRunning Head Discussion Board                                  .docx
Running Head Discussion Board .docx
jeanettehully
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdf
apleathers
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
infanciaj
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
shericehewat
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
dickonsondorris
 
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docxAssg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
festockton
 
MAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdfMAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdf
adityastores21
 
Describe a data structure to represent sets of elements (each element.pdf
Describe a data structure to represent sets of elements (each element.pdfDescribe a data structure to represent sets of elements (each element.pdf
Describe a data structure to represent sets of elements (each element.pdf
rajeshjain2109
 
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docxAssg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
festockton
 
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docxAvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
rock73
 
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
arihantelehyb
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
ravikapoorindia
 
On the code which has a class in which I implementing a binary tree .pdf
On the code which has a class in which I implementing a binary tree .pdfOn the code which has a class in which I implementing a binary tree .pdf
On the code which has a class in which I implementing a binary tree .pdf
wasemanivytreenrco51
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 

Similar to Required to augment the authors Binary Search Tree (BST) code to .docx (20)

Write a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdfWrite a C++ program that implements a binary search tree (BST) to man.pdf
Write a C++ program that implements a binary search tree (BST) to man.pdf
 
Binary Tree
Binary  TreeBinary  Tree
Binary Tree
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
Running Head Discussion Board .docx
Running Head Discussion Board                                  .docxRunning Head Discussion Board                                  .docx
Running Head Discussion Board .docx
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdf
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
 
611+tutorial
611+tutorial611+tutorial
611+tutorial
 
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docxAssg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
 
MAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdfMAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdf
 
Describe a data structure to represent sets of elements (each element.pdf
Describe a data structure to represent sets of elements (each element.pdfDescribe a data structure to represent sets of elements (each element.pdf
Describe a data structure to represent sets of elements (each element.pdf
 
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docxAssg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
 
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docxAvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
 
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
(Parent reference for BST) Redefine TreeNode by adding a reference to.pdf
 
List
ListList
List
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 
On the code which has a class in which I implementing a binary tree .pdf
On the code which has a class in which I implementing a binary tree .pdfOn the code which has a class in which I implementing a binary tree .pdf
On the code which has a class in which I implementing a binary tree .pdf
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 

More from debishakespeare

Ethical Case Study 2Gloria is a housekeeper in an independent li.docx
Ethical Case Study 2Gloria is a housekeeper in an independent li.docxEthical Case Study 2Gloria is a housekeeper in an independent li.docx
Ethical Case Study 2Gloria is a housekeeper in an independent li.docx
debishakespeare
 
Ethical consideration is important in nursing practice, especial.docx
Ethical consideration is important in nursing practice, especial.docxEthical consideration is important in nursing practice, especial.docx
Ethical consideration is important in nursing practice, especial.docx
debishakespeare
 
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docx
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docxEthical Competency Writing Assignment DescriptionPHI 108 Spr.docx
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docx
debishakespeare
 
Ethical Case StudyAn example of unethical treatment of participa.docx
Ethical Case StudyAn example of unethical treatment of participa.docxEthical Case StudyAn example of unethical treatment of participa.docx
Ethical Case StudyAn example of unethical treatment of participa.docx
debishakespeare
 
Ethical AwarenessDEFINITION a brief definition of the k.docx
Ethical AwarenessDEFINITION a brief definition of the k.docxEthical AwarenessDEFINITION a brief definition of the k.docx
Ethical AwarenessDEFINITION a brief definition of the k.docx
debishakespeare
 
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docxETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
debishakespeare
 
Ethical Conduct of Researchpower point from this document, 1.docx
Ethical Conduct of Researchpower point from this document, 1.docxEthical Conduct of Researchpower point from this document, 1.docx
Ethical Conduct of Researchpower point from this document, 1.docx
debishakespeare
 
Ethical Challenges and Agency IssuesI.IntroductionII.E.docx
Ethical Challenges and Agency IssuesI.IntroductionII.E.docxEthical Challenges and Agency IssuesI.IntroductionII.E.docx
Ethical Challenges and Agency IssuesI.IntroductionII.E.docx
debishakespeare
 
Ethical Approaches An Overview of .docx
Ethical Approaches An Overview of .docxEthical Approaches An Overview of .docx
Ethical Approaches An Overview of .docx
debishakespeare
 
Ethical and Professional Issues in Group PracticeThose who seek .docx
Ethical and Professional Issues in Group PracticeThose who seek .docxEthical and Professional Issues in Group PracticeThose who seek .docx
Ethical and Professional Issues in Group PracticeThose who seek .docx
debishakespeare
 
Ethical AnalysisSelect a work-related ethical scenario that .docx
Ethical AnalysisSelect a work-related ethical scenario that .docxEthical AnalysisSelect a work-related ethical scenario that .docx
Ethical AnalysisSelect a work-related ethical scenario that .docx
debishakespeare
 
Ethical (Moral) RelativismIn America, many are comfortable describ.docx
Ethical (Moral) RelativismIn America, many are comfortable describ.docxEthical (Moral) RelativismIn America, many are comfortable describ.docx
Ethical (Moral) RelativismIn America, many are comfortable describ.docx
debishakespeare
 
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docxEthical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
debishakespeare
 
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docx
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docxEthical Analysis on Merrill lynch financial crisis of 2008 , please .docx
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docx
debishakespeare
 
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docxETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
debishakespeare
 
Ethical and Human Rights Concerns in Global HealthChapter Fou.docx
Ethical and Human Rights Concerns in Global HealthChapter  Fou.docxEthical and Human Rights Concerns in Global HealthChapter  Fou.docx
Ethical and Human Rights Concerns in Global HealthChapter Fou.docx
debishakespeare
 
Ethical & Legal Aspects in Nursing WK 14Please answer the .docx
Ethical & Legal Aspects in Nursing WK 14Please answer the .docxEthical & Legal Aspects in Nursing WK 14Please answer the .docx
Ethical & Legal Aspects in Nursing WK 14Please answer the .docx
debishakespeare
 
EthernetSatellite dishInternational Plastics, Inc. - C.docx
EthernetSatellite dishInternational Plastics, Inc. -  C.docxEthernetSatellite dishInternational Plastics, Inc. -  C.docx
EthernetSatellite dishInternational Plastics, Inc. - C.docx
debishakespeare
 
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docxEthanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
debishakespeare
 
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docxEthan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
debishakespeare
 

More from debishakespeare (20)

Ethical Case Study 2Gloria is a housekeeper in an independent li.docx
Ethical Case Study 2Gloria is a housekeeper in an independent li.docxEthical Case Study 2Gloria is a housekeeper in an independent li.docx
Ethical Case Study 2Gloria is a housekeeper in an independent li.docx
 
Ethical consideration is important in nursing practice, especial.docx
Ethical consideration is important in nursing practice, especial.docxEthical consideration is important in nursing practice, especial.docx
Ethical consideration is important in nursing practice, especial.docx
 
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docx
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docxEthical Competency Writing Assignment DescriptionPHI 108 Spr.docx
Ethical Competency Writing Assignment DescriptionPHI 108 Spr.docx
 
Ethical Case StudyAn example of unethical treatment of participa.docx
Ethical Case StudyAn example of unethical treatment of participa.docxEthical Case StudyAn example of unethical treatment of participa.docx
Ethical Case StudyAn example of unethical treatment of participa.docx
 
Ethical AwarenessDEFINITION a brief definition of the k.docx
Ethical AwarenessDEFINITION a brief definition of the k.docxEthical AwarenessDEFINITION a brief definition of the k.docx
Ethical AwarenessDEFINITION a brief definition of the k.docx
 
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docxETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
ETHICAL CHALLENGES JOYCAROLYNE MUIGAINTC3025262020.docx
 
Ethical Conduct of Researchpower point from this document, 1.docx
Ethical Conduct of Researchpower point from this document, 1.docxEthical Conduct of Researchpower point from this document, 1.docx
Ethical Conduct of Researchpower point from this document, 1.docx
 
Ethical Challenges and Agency IssuesI.IntroductionII.E.docx
Ethical Challenges and Agency IssuesI.IntroductionII.E.docxEthical Challenges and Agency IssuesI.IntroductionII.E.docx
Ethical Challenges and Agency IssuesI.IntroductionII.E.docx
 
Ethical Approaches An Overview of .docx
Ethical Approaches An Overview of .docxEthical Approaches An Overview of .docx
Ethical Approaches An Overview of .docx
 
Ethical and Professional Issues in Group PracticeThose who seek .docx
Ethical and Professional Issues in Group PracticeThose who seek .docxEthical and Professional Issues in Group PracticeThose who seek .docx
Ethical and Professional Issues in Group PracticeThose who seek .docx
 
Ethical AnalysisSelect a work-related ethical scenario that .docx
Ethical AnalysisSelect a work-related ethical scenario that .docxEthical AnalysisSelect a work-related ethical scenario that .docx
Ethical AnalysisSelect a work-related ethical scenario that .docx
 
Ethical (Moral) RelativismIn America, many are comfortable describ.docx
Ethical (Moral) RelativismIn America, many are comfortable describ.docxEthical (Moral) RelativismIn America, many are comfortable describ.docx
Ethical (Moral) RelativismIn America, many are comfortable describ.docx
 
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docxEthical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
Ethical Analysis on Lehman Brothers financial crisis of 2008 , pleas.docx
 
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docx
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docxEthical Analysis on Merrill lynch financial crisis of 2008 , please .docx
Ethical Analysis on Merrill lynch financial crisis of 2008 , please .docx
 
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docxETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
ETHC 101Discussion Board Reply Grading RubricCriteriaLevels .docx
 
Ethical and Human Rights Concerns in Global HealthChapter Fou.docx
Ethical and Human Rights Concerns in Global HealthChapter  Fou.docxEthical and Human Rights Concerns in Global HealthChapter  Fou.docx
Ethical and Human Rights Concerns in Global HealthChapter Fou.docx
 
Ethical & Legal Aspects in Nursing WK 14Please answer the .docx
Ethical & Legal Aspects in Nursing WK 14Please answer the .docxEthical & Legal Aspects in Nursing WK 14Please answer the .docx
Ethical & Legal Aspects in Nursing WK 14Please answer the .docx
 
EthernetSatellite dishInternational Plastics, Inc. - C.docx
EthernetSatellite dishInternational Plastics, Inc. -  C.docxEthernetSatellite dishInternational Plastics, Inc. -  C.docx
EthernetSatellite dishInternational Plastics, Inc. - C.docx
 
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docxEthanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
Ethanolv.DrizinUnited States District Court, N.D. Iowa, Eastern .docx
 
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docxEthan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
Ethan FromeEdith WhartonTHE EMC MASTERPIECE SERIES.docx
 

Recently uploaded

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 

Recently uploaded (20)

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 

Required to augment the authors Binary Search Tree (BST) code to .docx

  • 1. Required to augment the author's Binary Search Tree (BST) code to support these new operations. Method names below are merely suggestions. (The author’s class is attached separately in the file called “authordoc”. I just built a simple test tree in the author’s main method which can be used to test the various operations. ) 1. AnyType nthElement(int n) -- returns the n-th element (starting from 1) of the in-order traversal of the BST. 2. int rank( AnyType x ) -- returns the "rank" of x. The rank of an element is its position (starting with 1) in an in-order traversal. 3. AnyType median( ) -- returns the median (middle) element in the BST. If the BST contains an even number of elements, returns the smaller of the two medians. 4. boolean isPerfect( ) -- returns true if the BST is a perfect binary tree. 5. boolean isComplete( ) -- returns true if the BST is a complete binary tree. 6. String toString( int nrLevels ) -- generates the level-order output described in the sample output below. Most of these operations could easily be implemented by performing an in-order traversal inside the BST and perhaps placing the results in an ArrayList. However, such a method is extremely inefficient. Instead, we are going to achieve faster performance by "augmenting" the BST nodes. You will add a new private integer data member ("tree size") to the BinaryNode which stores the size of the tree rooted at that node (including the root). You must develop your own algorithms for these operations, but obviously you will use the new tree size data member to guide your search. Think before you code and think recursively! These items cover those topics not addressed elsewhere in the project description. (R) indicates a requirement, (H) indicates a
  • 2. hint, and (N) indicates a note. 1. (R) Although we are only using the BST for integers, the BST must remain a generic class. 2. (R) Duplicate values are not allowed. Attempts to insert a duplicate value should be ignored. 3. (R) Attempts to remove non-existent values should be ignored. 4. (R) From a coding perspective, the easiest way to avoid duplicate insertions or attempting to remove non-existent elements is to first call find( ). However, this technique is NOT permitted for two reasons. Calling find( ) before each insert/remove doubles the running time for these operations and is therefore inefficient. Recusively coding the insert/remove methods to handle these situations is a great learning experience. 5. (R) The level order print (PRINT command) outputs the value of each node, the size of the tree rooted at that node, and the value of the node's parent in that order, inside parenthesis, separated by commas. (node value, tree size, parent value). Since the root has no parent, print NULL for the root's parent value. For readability, separate the levels with a blank line and print no more than 6 node/size/parent values per line. If a level requires multiple lines, use consecutive lines (without a blank line between them). 6. (R) Efficieny counts! Use the most efficient algorithm possible In particular, don't make multiple searches in the tree when one will do. (Yes, we know it doesn't matter from an asymptotic analysis point of view.) 7. (H) Almost all of these operations should be written recursively, but not necessarily all of them. 8. (N) As is customary, your BST class should not provide any methods for printing. However, the BST can provide a method that formats a string containing information that the user wishes to print. Overloading the toString( ) method is a common technique to achieve this kind of functionality.
  • 3. Note: The instructor noted that once the tree is built, it will not be changed during testing of the program. (just to simplify the task if that helps) package Ast.rt; import java.util.ArrayList; // BinarySearchTree class // // CONSTRUCTION: with no initializer // // ******************PUBLIC OPERATIONS********************* // void insert( x ) --> Insert x // void remove( x ) --> Remove x // boolean contains( x ) --> Return true if x is present // Comparable findMin( ) --> Return smallest item
  • 4. // Comparable findMax( ) --> Return largest item // boolean isEmpty( ) --> Return true if empty; else false // void makeEmpty( ) --> Remove all items // void printTree( ) --> Print tree in sorted order // ******************ERRORS*************************** ***** // Throws UnderflowException as appropriate /** * Implements an unbalanced binary search tree. * Note that all "matching" is based on the compareTo method. * @author Mark Allen Weiss */ public class BinarySearchTree<AnyType extends Comparable<? super AnyType>> { /** * Construct the tree. */
  • 5. public BinarySearchTree( ) { root = null; } /** * Insert into the tree; duplicates are ignored. * @param x the item to insert. */ public void insert( AnyType x ) { root = insert( x, root ); } /** * Remove from the tree. Nothing is done if x is not found. * @param x the item to remove. */
  • 6. public void remove( AnyType x ) { root = remove( x, root ); } /** * Find the smallest item in the tree. * @return smallest item or null if empty. * @throws Exception */ public AnyType findMin( ) throws Exception { if( isEmpty( ) ) throw new Exception( ); return findMin( root ).element;
  • 7. } /** * Find the largest item in the tree. * @return the largest item of null if empty. * @throws Exception */ public AnyType findMax( ) throws Exception { if( isEmpty( ) ) throw new Exception( ); return findMax( root ).element; } /** * Find an item in the tree. * @param x the item to search for. * @return true if not found.
  • 8. */ public boolean contains( AnyType x ) { return contains( x, root ); } /** * Make the tree logically empty. */ public void makeEmpty( ) { root = null; } /** * Test if the tree is logically empty. * @return true if empty, false otherwise. */
  • 9. public boolean isEmpty( ) { return root == null; } /** * Print the tree contents in sorted order. */ public void printTree( ) { if( isEmpty( ) ) System.out.println( "Empty tree" ); else printTree( root ); } /** * Internal method to insert into a subtree.
  • 10. * @param x the item to insert. * @param t the node that roots the subtree. * @return the new root of the subtree. */ private BinaryNode<AnyType> insert( AnyType x, BinaryNode<AnyType> t ) { if( t == null ) return new BinaryNode<AnyType>( x, null, null); int compareResult = x.compareTo( t.element ); if( compareResult < 0 ){ t.left = insert( x, t.left ); } else if( compareResult > 0 ){ t.right = insert( x, t.right );
  • 11. } else ; // Duplicate; do nothing return t; } /** * Internal method to remove from a subtree. * @param x the item to remove. * @param t the node that roots the subtree. * @return the new root of the subtree. */ private BinaryNode<AnyType> remove( AnyType x, BinaryNode<AnyType> t ) { if( t == null ) return t; // Item not found; do nothing int compareResult = x.compareTo( t.element );
  • 12. if( compareResult < 0 ) t.left = remove( x, t.left ); else if( compareResult > 0 ) t.right = remove( x, t.right ); else if( t.left != null && t.right != null ) // Two children { t.element = findMin( t.right ).element; t.right = remove( t.element, t.right ); } else t = ( t.left != null ) ? t.left : t.right; return t; } /** * Internal method to find the smallest item in a subtree. * @param t the node that roots the subtree.
  • 13. * @return node containing the smallest item. */ private BinaryNode<AnyType> findMin( BinaryNode<AnyType> t ) { if( t == null ) return null; else if( t.left == null ) return t; return findMin( t.left ); } /** * Internal method to find the largest item in a subtree. * @param t the node that roots the subtree. * @return node containing the largest item. */ private BinaryNode<AnyType> findMax( BinaryNode<AnyType> t )
  • 14. { if( t != null ) while( t.right != null ) t = t.right; return t; } /** * Internal method to find an item in a subtree. * @param x is item to search for. * @param t the node that roots the subtree. * @return node containing the matched item. */ private boolean contains( AnyType x, BinaryNode<AnyType> t ) {
  • 15. if( t == null ) return false; int compareResult = x.compareTo( t.element ); if( compareResult < 0 ) return contains( x, t.left ); else if( compareResult > 0 ) return contains( x, t.right ); else return true; // Match } /** * Internal method to print a subtree in sorted order. * @param t the node that roots the subtree. */ private void printTree( BinaryNode<AnyType> t )
  • 16. { if( t != null ) { printTree( t.left ); System.out.println( t.element ); printTree( t.right ); } } /** * Internal method to compute height of a subtree. * @param t the node that roots the subtree. */ private int height( BinaryNode<AnyType> t ) { if( t == null ) return -1; else
  • 17. return 1 + Math.max( height( t.left ), height( t.right ) ); } // Basic node stored in unbalanced binary search trees private static class BinaryNode<AnyType> { // Constructors BinaryNode( AnyType theElement ) { this( theElement, null, null); } BinaryNode( AnyType theElement, BinaryNode<AnyType> lt, BinaryNode<AnyType> rt) { element = theElement; left = lt;
  • 18. right = rt; } AnyType element; // The data in the node BinaryNode<AnyType> left; // Left child BinaryNode<AnyType> right; // Right child int treeSize; } /** The tree root. */ private BinaryNode<AnyType> root;
  • 19. // Test program public static void main( String [ ] args ) throws Exception { BinarySearchTree<Integer> t = new BinarySearchTree<Integer>( ); int[] nums = new int[] {55, 40, 60, 30, 45, 70, 20, 35, 44, 47, 66, 80, 3, 36, 37, 43, 48, 65, 67, 77, 90}; for(int i = 0; i < nums.length; i++) t.insert(nums[i]); t.printTree(); System.out.println( "Checking... (no more output means success)" );
  • 20. } }