IMPLEMENTE OF BINARY TREE
JAVA PROGRAM:-
import java.util.Scanner;
public class tree {
static Scanner sc =null;
public static void main(String args[]){
sc=new Scanner(System.in);//use to take input
createTree();// call the function
}
static Node createTree(){
Node root=null;
System.out.print("Enter data:");
int data=sc.nextInt();
if(data==-1)return null;
root =new Node(data);
System.out.print("Enter the number of left part-"+data);
root.left=createTree();
System.out.print("Enter the number of right part-"+data);
root.right=createTree();
return root;
}
}
class Node{
Node left,right ;
int data;
public Node(int data){
this .data=data;
left=right=null;
}
}