diff --git a/src/ScuffedLinkedList/BonsaiLeaf.java b/src/ScuffedLinkedList/BonsaiLeaf.java new file mode 100644 index 0000000..4c4dfac --- /dev/null +++ b/src/ScuffedLinkedList/BonsaiLeaf.java @@ -0,0 +1,11 @@ +package ScuffedLinkedList; + +public class BonsaiLeaf { + BonsaiLeaf left; + BonsaiLeaf right; + int value; + + public BonsaiLeaf(int value) { + this.value = value; + } +} diff --git a/src/ScuffedLinkedList/BonsaiTree.java b/src/ScuffedLinkedList/BonsaiTree.java new file mode 100644 index 0000000..2ec812f --- /dev/null +++ b/src/ScuffedLinkedList/BonsaiTree.java @@ -0,0 +1,54 @@ +package ScuffedLinkedList; + +public class BonsaiTree { + public BonsaiLeaf root; + + + + public void add(int value) + { + root = add(value,this.root); + } + public BonsaiLeaf add(int value,BonsaiLeaf root) + { + + if(root == null) + + root = new BonsaiLeaf(value); + + else if(value > root.value) + root.right = add(value, root.right); + else + root.left = add(value,root.left); + + return root; + } + public void search(int value) + { + search(value,root); + } + public void search(int value,BonsaiLeaf root) + { + if(root == null) + System.out.println("NOT FOUND!!!!!!!!!!!!!"); + else if(root.value == value) + System.out.println("Found!"); + else if(value>root.value) + search(value,root.right); + else if(value