insert data into binary tree java code example
Example: binary search tree insert java
public static Node insert(Node root, int x){
if (root == null)
return new Node(x);
else if(x>root.getData())
root.setRightChild(insert(root.getRightChild(),x));
else
root.setLeftChild(insert(root.getLeftChild(),x));
return root;
}