public void inOrder(Node1 node)
{
if(node != null)
{
inOrder(node.left);
node.displayData();
inOrder(node.right);
}
}
public void preOrder(Node1 node)
{
if(node =! null){
node.displayData();
preOrder(node.left);
preOrder(node.right);
}
}
public void postOrder(Node1 node)
{
if(node != null)
{
postOrder(node.left);
postOrder(node.right);
node.displayData();
}
}
public static void main(String[] agrs)
{
traversal bst = new traversel();
bst.insert(25);
bst,insert(10);
bst.insert(15);
bst.insert(89);
bst.insert(79);
System.out.println("Inorder traversal of binary tree");
bst.inOrder(bst.root1);
System.out.println();
System.out.println("Preorder traversal of binary tree");
bst.preOrder(bst.root1);
System.out.println();
System.out.println("Postorder traversal of binary tree");
bst.postOrder(bst.root1);
System.out.println();
}
}
This is my Binary tree pre order, post order and in order code.in this code the output is not visible and it shows an error. I couldn’t find the error in here.
can someone help me to solve this.
New contributor
Madhushan Gamage is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.