I have written the following code to check if a tree is a Binary search tree. Please help me check the code:
Okay! The code is edited now. This simple solution was sugge
public void inorder()
{
min=min(root);
//System.out.println(min);
inorder(root);
}
private int min(BSTNode r)
{
while (r.left != null)
{
r=r.left;
}
return r.data;
}
private void inorder(BSTNode r)
{
if (r != null)
{
inorder(r.getLeft());
System.out.println(r.getData());
if(min<=r.getData())
{
System.out.println(min+"<="+r.getData());
min=r.getData();
}
else
System.out.println("nananan");
//System.out.print(r.getData() +" ");
inorder(r.getRight());
return;
}
}