Advertisement
Samuel_Berkat_Hulu

sdgsd

Jun 9th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. class Main{
  2.     public static void main(String[] args)  {
  3.  
  4.         BST_class bst = new BST_class();
  5.  
  6.         bst.insert(35);
  7.         bst.insert(1);
  8.         bst.insert(99);
  9.         bst.insert(67);
  10.         bst.insert(89);
  11.         bst.insert(34);
  12.  
  13.         System.out.println("BST printed inorder:");
  14.         bst.inorder();
  15.        
  16.  
  17.         System.out.println("\nThe BST after Delete 99(leaf node):");
  18.         bst.deleteKey(99);
  19.         bst.inorder();
  20.  
  21.         System.out.println("\nThe BST after Delete 34 (node with 1 child):");
  22.         bst.deleteKey(34);
  23.         bst.inorder();
  24.                  
  25.         System.out.println("\nThe BST after Delete 67 (Node with two children):");
  26.         bst.deleteKey(67);
  27.         bst.inorder();
  28.  
  29.         boolean ret_val = bst.search(89);
  30.         System.out.println("\nKey 89 found in BST:" + ret_val );
  31.         ret_val = bst.search(60);
  32.         System.out.println("\nKey 60 found in BST:" + ret_val );
  33.      }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement