-
-
Save piyushdubey/a57a2e7dfec783e34f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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