One test case is not working

private boolean structurallyIdentical(Node n1, Node n2) {
if(n1==null && n2==null)
{
return true;
}
if(n1!=null && n2!=null)
{
return n1.data==n2.data && structurallyIdentical(n1.left,n2.left) &&
structurallyIdentical(n1.right,n2.right);
}
return false;

	}

@Narasimha,
Don’t take n1.data==n2.data in this if(n1!=null && n2!=null) block of code.
Instead do this only:
if(n1!=null && n2!=null)
{
return structurallyIdentical(n1.left,n2.left) && structurallyIdentical(n1.right,n2.right);
}

sir,here we need to check only structure or data values also ?

@Narasimha,
Only structure

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.