Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rampatra/Algorithms-and-Data-Structures-in-Java
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: tuanon/Algorithms-and-Data-Structures-in-Java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

There isn’t anything to compare.

rampatra:master and tuanon:master are entirely different commit histories.

Showing with 15 additions and 12 deletions.
  1. +15 −12 src/me/ramswaroop/trees/CheckForBST.java
27 changes: 15 additions & 12 deletions src/me/ramswaroop/trees/CheckForBST.java
Original file line number Diff line number Diff line change
@@ -104,21 +104,24 @@ public static void main(String a[]) {
binarySearchTree.put(7);
binarySearchTree.put(8);
binarySearchTree.put(9);
out.println("Is BST: ");
out.println(isBST(binarySearchTree.root, new BinaryNode<Integer>(null)));
out.println("1) Is BST: ");
out.println(isBST(binarySearchTree.root, new BinaryNode<>(null))); // should be true

BinaryTree<Integer> binaryTree = new BinaryTree<>();
binaryTree.put(6);
binaryTree.put(3);
binaryTree.put(5);
binaryTree.put(7);
binaryTree.put(8);
binaryTree.put(4);
binaryTree.put(9);
out.println("Is BST: ");
out.println(isBST(binaryTree.root, new BinaryNode<Integer>(null)));
binaryTree.put(2);
binaryTree.put(8);
binaryTree.put(7);
binaryTree.put(10);
out.println("2) Is BST: ");
out.println(isBST(binaryTree.root, new BinaryNode<>(null))); // should be false

// min max approach
out.println("Is BST: ");
out.println(isBST(binarySearchTree.root, Integer.MIN_VALUE, Integer.MAX_VALUE));
out.println("Is BST: ");
out.println(isBST(binaryTree.root, Integer.MIN_VALUE, Integer.MAX_VALUE));
out.println("3) Is BST: ");
out.println(isBST(binarySearchTree.root, Integer.MIN_VALUE, Integer.MAX_VALUE)); // should be true
out.println("4) Is BST: ");
out.println(isBST(binaryTree.root, Integer.MIN_VALUE, Integer.MAX_VALUE)); // should be false
}
}