rendered paste body/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package main;
/**
*
* @author kusum
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author kusum
*/
import java.io.*;
import java.util.*;
public class one
{
node root;
public one()
{
root=new node(true);
root.name="root";
insert();
System.out.println("inorder");
//inorder(root);
}
public node insert_node(node root,node left,node right)
{
try{
System.out.println(root.name);
if(root.left==null)
{
root.left=new node(true);
root.right=new node(false);
root.left=left;
root.right=right;
}
else
{
node temp=insert_node(root.left,left,right);
root.left=temp;
root.right=insert_node(root.right,left,right);
}
}catch(Exception e)
{
System.out.println(e);
}
return root;
}
public void insert()
{
try
{
BufferedReader br = new BufferedReader(new InputStreamReader
(System.in));
int count=Integer.parseInt(br.readLine());
while(count>0)
{
System.out.println(" ");
String temp[]=(br.readLine()).split(" ");
node tmp=new node(true);
tmp.name=temp[0];
tmp.value=Integer.parseInt(temp[1]);
node tmp2=new node(false);
tmp2.name=temp[0];
tmp2.value=Integer.parseInt(temp[1]);
this.root=insert_node(this.root,tmp,tmp2);
count--;
}
}catch(Exception e)
{
e.printStackTrace();
}
}
public void preorder(node n)
{
}
public void inorder(node n)
{
if(n.left!=null)
{
inorder(n.left);
System.out.println(n.name);
inorder(n.right);
}
else
{
}
}
public static void main(String argsp[])
{
new one();
}
}
class node{
String name;
int value;
node left;
node right;
boolean state;
public node(boolean state)
{
name="@";
left=null;
right=null;
this.state=state;
}
}