Hello can you help me please how can i get the leaf in the Binary Tree.I Dont have idea on the leaf?...can you help me please thank you in advance hoping for your positive response...
here is my code...
public void insertNum(int n)
{
Node temp=null;
Node current=null;
Node newNode = new Node();
newNode.num=n;
if(isEmpty())
{
root=newNode;
System.out.println("Successfully inserted!");
return;
}
temp=root;
while(temp!=null)
{
if(temp.num==n)
{
return;
}
if(temp.num<n)
{
current=temp;
if(temp.rlink==null)
{
temp.rlink=newNode;
System.out.println("Inserted at the right= "+current.num);
}
else
{
temp=temp.rlink;
}
}
else
{
current=temp;
if(temp.llink==null)
{
temp.llink=newNode;
System.out.println("Inserted at the left= "+current.num);
}
else
{
temp=temp.llink;
}
}
}
}