Skip to content

Instantly share code, notes, and snippets.

@chaudharisuresh997
Last active December 26, 2019 07:01
Show Gist options
  • Save chaudharisuresh997/b7f3f8b8ec6e7b27e6be8c53d6918ab0 to your computer and use it in GitHub Desktop.
Save chaudharisuresh997/b7f3f8b8ec6e7b27e6be8c53d6918ab0 to your computer and use it in GitHub Desktop.
BinaryTree create tree data
reate Binary search tree
TreeNode t8=new TreeNode(8);
TreeNode t3=new TreeNode(3);
TreeNode t1=new TreeNode(1);
TreeNode t6=new TreeNode(6);
TreeNode t10=new TreeNode(10);
TreeNode t9=new TreeNode(9);
TreeNode t14=new TreeNode(14);
t8.left=t3;
t8.right=t10;
t3.left=t1;
t3.right=t6;
t10.left=t9;
t10.right=t14;
Tse t=new Tse();
Create Simple tree
TreeNode t6=new TreeNode();
t6.val=6;
TreeNode t7=new TreeNode();
t7.val=7;
TreeNode t3=new TreeNode();
t3.val=3;
t3.left=t6;
t3.right=t7;
TreeNode t4=new TreeNode();
t4.val=4;
TreeNode t5=new TreeNode();
t5.val=5;
TreeNode t2=new TreeNode();
t2.val=2;
t2.left=t4;
t2.right=t5;
TreeNode t1=new TreeNode();
t1.val=1;
t1.left=t2;
t1.right=t3;
Tree t6=new Tree();
t6.data=6;
Tree t7=new Tree();
t7.data=7;
Tree t3=new Tree();
t3.data=3;
t3.left=t6;
t3.right=t7;
Tree t4=new Tree();
t4.data=4;
Tree t5=new Tree();
t5.data=5;
Tree t2=new Tree();
t2.data=2;
t2.left=t4;
t2.right=t5;
Tree t1=new Tree();
t1.data=1;
t1.left=t2;
t1.right=t3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment