if (node1.value != node2.value)
return false; /* Accessing node1.value and node2.value without check for nulls*/
if(node1 != null && node2 != null)
{
if(node1.leftChild.value == node2.leftChild.value)/* Null problems with left and right child*/
isIsomorphic(node1.leftChild, node2.leftChild)
else if(node1.leftChild.value == node2.rightChild.value ) /*""*/
isIsomorphic(node1.leftChild, node2.rightChild)
if(node1.rightChild.value == node2.leftChild.value)/*""*/
isIsomorphic(node1.rightChild, node2.leftChild)
else if( node1.rightChild.value == node2.rightChild.value)/*""*/
isIsomorphic(node1.rightChild, node2.rightChild)
}
return true;
The other problem is that if there are duplicate values..say both children have same value 1 in both the trees...we need to check both the left to left matching and left to right matching
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---