[algogeeks] Re: isomorphism

2006-10-27 Thread Arunachalam
Deepak manohar's solution is an elegant one. This is very clumsy and you have a bug too. On 10/27/06, sivaramakrishna kantharao [EMAIL PROTECTED] wrote: hi how abt the following one int IsIsomorphic(tree *temp1,tree *temp2){if(temp1==NULL temp2==NULL)return 1;else if(temp1!=NULL temp2!=NULL){

[algogeeks] Re: isomorphism

2006-10-26 Thread None
great, thanks a lot this helps, i had something similar to Deepak --~--~-~--~~~---~--~~ 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

[algogeeks] Re: isomorphism

2006-10-26 Thread None
would this work: if (node1.value != node2.value) return false; if(node1 != null node2 != null) { if(node1.leftChild.value == node2.leftChild.value) isIsomorphic(node1.leftChild, node2.leftChild) else if(node1.leftChild.value == node2.rightChild.value)

[algogeeks] Re: isomorphism

2006-10-26 Thread None
hrmm.. so would Deepak's method work? it seems to be ok... i just dont understand the final line return node1 == null node2 == null; why is this needed? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Re: isomorphism

2006-10-25 Thread Karthik Singaram L
Let us say we call the following with the roots of both the treesalgo: checkIsomorphism (node1, node2){ if(node1==NULL node2==NULL) return 1; if(node1==NULL) return 0; if(node2==NULL) return 0; child11=node1-left; child12=node1-right; child21=node2-left; child22=node2-right;

[algogeeks] Re: isomorphism

2006-10-25 Thread Deepak Manohar
I see potential nullpointers in the code.(marked in bold)Another recursive solution:isIsomorphic(node1, node2){ if (node1 != null node2 != null) { if (node1-value != node2-value) return 0; if (isIsomorphic(node1-left, node2-left) isIsomorphic(node1-right, node2-right)) return 1; if