Skip to content

Instantly share code, notes, and snippets.

@piyushdubey
Created December 7, 2015 23:45
Show Gist options
  • Select an option

  • Save piyushdubey/a57a2e7dfec783e34f2e to your computer and use it in GitHub Desktop.

Select an option

Save piyushdubey/a57a2e7dfec783e34f2e to your computer and use it in GitHub Desktop.
public class BST {
public boolean insert(BinaryTreeNode root, String value) {
if(root == null) {
root = new BinaryTreeNode(value, null, null);
} else {
if(root.value.compareTo(value) > 0) {
insert(root.left, value);
} else if(root.value.compareTo(value) <= 0) {
insert(root.right, value);
}
}
}
public void delete()
}
class BinaryTreeNode {
String value;
BinaryTreeNode left;
BinaryTreeNode right;
BinaryTreeNode(String value) {
this.value = value;
}
BinaryTreeNode(String value, BinaryTreeNode left, BinaryTreeNode right) {
this.value = value;
this.left = left;
this.right = right;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment