From edaba0cff9ad89207817c2fc99fb3e8f99a29318 Mon Sep 17 00:00:00 2001 From: Kratika Agrawal <64762103+Kratika28-agr@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:43:11 +0530 Subject: [PATCH 1/2] Create BinaryTreeImplementation --- src-java/BinaryTreeImplementation | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src-java/BinaryTreeImplementation diff --git a/src-java/BinaryTreeImplementation b/src-java/BinaryTreeImplementation new file mode 100644 index 0000000..4fd763f --- /dev/null +++ b/src-java/BinaryTreeImplementation @@ -0,0 +1,31 @@ +public class BinaryTree{ + private TreeNode root; + private class TreeNode{ + private TreeNode left; + private TreeNode right; + private TreeNode null; + + public TreeNode(int data){ + this.data=data; + } + } + + public void createBT(){ + TreeNode first=new TreeNode(1); + TreeNode second=new TreeNode(2); + TreeNode third=new TreeNode(3); + TreeNode fourth=new TreeNode(4); + TreeNode fifth=new TreeNode(5); + + root=first; + first.left=second; + first.right=third; + second.left=fourth; + second.right=fifth; + } + + public static void main(String args[]){ + BinaryTree bt=new BinaryTree(); + bt.createBT(); + } +} From 73ca65dd55b97e04aa272be81286a0831a19d0d7 Mon Sep 17 00:00:00 2001 From: Kratika Agrawal <64762103+Kratika28-agr@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:43:53 +0530 Subject: [PATCH 2/2] Create BinaryTree Implementation --- src-java/BinaryTree Implementation | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src-java/BinaryTree Implementation diff --git a/src-java/BinaryTree Implementation b/src-java/BinaryTree Implementation new file mode 100644 index 0000000..4fd763f --- /dev/null +++ b/src-java/BinaryTree Implementation @@ -0,0 +1,31 @@ +public class BinaryTree{ + private TreeNode root; + private class TreeNode{ + private TreeNode left; + private TreeNode right; + private TreeNode null; + + public TreeNode(int data){ + this.data=data; + } + } + + public void createBT(){ + TreeNode first=new TreeNode(1); + TreeNode second=new TreeNode(2); + TreeNode third=new TreeNode(3); + TreeNode fourth=new TreeNode(4); + TreeNode fifth=new TreeNode(5); + + root=first; + first.left=second; + first.right=third; + second.left=fourth; + second.right=fifth; + } + + public static void main(String args[]){ + BinaryTree bt=new BinaryTree(); + bt.createBT(); + } +}