-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathInorder.java
34 lines (32 loc) · 872 Bytes
/
Inorder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class Inorder
{
public static void main(String[] args)
{
BinaryTreeNode ROOT = null;
BinaryTreeNode a = new BinaryTreeNode(1);
BinaryTreeNode b = new BinaryTreeNode(2);
BinaryTreeNode c = new BinaryTreeNode(3);
BinaryTreeNode d = new BinaryTreeNode(4);
BinaryTreeNode e = new BinaryTreeNode(5);
BinaryTreeNode f = new BinaryTreeNode(6);
BinaryTreeNode g = new BinaryTreeNode(7);
ROOT=a;
ROOT.setLeft(b);
ROOT.setRight(c);
b.setLeft(d);
b.setRight(e);
c.setLeft(f);
c.setRight(g);
inorder(ROOT);
}
public static void inorder(BinaryTreeNode ROOT)
{
if(ROOT==null)
{
return;
}
inorder(ROOT.left);
System.out.print(ROOT.data+" ");
inorder(ROOT.right);
}
}