File tree 1 file changed +15
-12
lines changed
1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -104,21 +104,24 @@ public static void main(String a[]) {
104
104
binarySearchTree .put (7 );
105
105
binarySearchTree .put (8 );
106
106
binarySearchTree .put (9 );
107
- out .println ("Is BST: " );
108
- out .println (isBST (binarySearchTree .root , new BinaryNode <Integer >(null )));
107
+ out .println ("1) Is BST: " );
108
+ out .println (isBST (binarySearchTree .root , new BinaryNode <>(null ))); // should be true
109
+
109
110
BinaryTree <Integer > binaryTree = new BinaryTree <>();
110
111
binaryTree .put (6 );
111
- binaryTree .put (3 );
112
- binaryTree .put (5 );
113
- binaryTree .put (7 );
114
- binaryTree .put (8 );
112
+ binaryTree .put (4 );
115
113
binaryTree .put (9 );
116
- out .println ("Is BST: " );
117
- out .println (isBST (binaryTree .root , new BinaryNode <Integer >(null )));
114
+ binaryTree .put (2 );
115
+ binaryTree .put (8 );
116
+ binaryTree .put (7 );
117
+ binaryTree .put (10 );
118
+ out .println ("2) Is BST: " );
119
+ out .println (isBST (binaryTree .root , new BinaryNode <>(null ))); // should be false
120
+
118
121
// min max approach
119
- out .println ("Is BST: " );
120
- out .println (isBST (binarySearchTree .root , Integer .MIN_VALUE , Integer .MAX_VALUE ));
121
- out .println ("Is BST: " );
122
- out .println (isBST (binaryTree .root , Integer .MIN_VALUE , Integer .MAX_VALUE ));
122
+ out .println ("3) Is BST: " );
123
+ out .println (isBST (binarySearchTree .root , Integer .MIN_VALUE , Integer .MAX_VALUE )); // should be true
124
+ out .println ("4) Is BST: " );
125
+ out .println (isBST (binaryTree .root , Integer .MIN_VALUE , Integer .MAX_VALUE )); // should be false
123
126
}
124
127
}
You can’t perform that action at this time.
0 commit comments