Let us say we call the following with the roots of both the trees

algo: 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;


 
   if((child11==NULL && child21==NULL) || (child11->value==child21->value))
   {
      if((child12==NULL && child 22==NULL) || (child12->value==child22->value)
      {
           if((child11==NULL && child12==NULL) || (child11->value==child12->value))
           {
             if((checkIsomorphism(child11, child21) && checkIsomorphism(child12, child22)) || (checkIsomorphism(child11, child22) && checkIsomorphism(child12, child21))
                 return 1;
              else
                 return 0;
           }
           else
           {
            if(checkIsomorphism (child11, child21) && checkIsomorphism(child12, child22))
              return 1;
            else
               return 0;
           }
      }
      else
      {
          return 0;
      }
   }
   else
   {
        if((child11==NULL && child22==NULL) || (child11->value == child22->value))
        {
           if(checkIsomorphism(child11, child22) && checkIsomorphism(child12, child21))
           return 1;
        }
        else
          return 0;
   }
}



On 10/25/06, None <[EMAIL PROTECTED]> wrote:

Hello, how can I compare two trees that only have ints for
isomorphism...
can someone show me a simple algorithm to do this...






--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to