class Node
{
int data;
Node left;
Node right;
Node(int n)
{
data=n;
left=null;
right=null;
}
}
class BinaryTree
{
Node root;
int pos;
BinaryTree()
{
root=null;
}
public Node dfs(int[] arr)
{
if(arr[pos]==0)
{
return null;
}
Node node=new Node(arr[pos]);
pos++;
node.left=dfs(arr);
pos++;
node.right=dfs(arr);
return node;
}
public void createTree(int arr[])
{
pos=0;
root=dfs(arr);
}
public void dfs2(Node root)
{
System.out.print(root.data);
if (root.left!=null) {
dfs2(root.left);
}
if (root.right!=null) {
dfs2(root.right);
}
}
public void show()
{
dfs2(root);
}
}
public class Test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
BinaryTree bTree=new BinaryTree();
int[] arr={1,2,0,0,3,0,0};
bTree.createTree(arr);
bTree.show();
}
}