Skip to content

Commit 5d1e291

Browse files
committed
btree
1 parent 9fa9b2d commit 5d1e291

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Trees/btree.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
class Node
3+
{
4+
int data;
5+
Node left;
6+
Node right;
7+
Node(int data)
8+
{
9+
this.data=data;
10+
left=right=null;
11+
}
12+
}
13+
14+
class BinaryTree{
15+
Node root;
16+
BinaryTree()
17+
{
18+
root = null;
19+
}
20+
BinaryTree(int data)
21+
{
22+
this.root=new Node(data);
23+
}
24+
}
25+
26+
class btree{
27+
public static void main(String[] args) {
28+
29+
BinaryTree bt=new BinaryTree(2);
30+
bt.root.left=new Node(3);
31+
bt.root.right=new Node(5);
32+
bt.root.left.right=new Node(9);
33+
bt.root.right.left=new Node(7);
34+
35+
}
36+
}

0 commit comments

Comments
 (0)