forked from joharbatta/DataStructure-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinorder.java
More file actions
33 lines (32 loc) · 769 Bytes
/
Copy pathinorder.java
File metadata and controls
33 lines (32 loc) · 769 Bytes
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
import java.util.*;
class Inorder
{
Node root;
Inorder()
{
root = null;
}
void printInorder(Node node)
{
if (node == null)
return;
printInorder(node.left);
System.out.print(node.key + " ");
printInorder(node.right);
}
void printInorder()
{
printInorder(root);
}
public static void main(String[] args)
{
Inorder tree = new Inorder();
tree.root = new Node(1);
tree.root.left = new Node(2);
tree.root.right = new Node(3);
tree.root.left.left = new Node(4);
tree.root.left.right = new Node(5);
System.out.println("\nInorder traversal of binary tree is ");
tree.printInorder();
}
}