my solution
*isomorphic* (struct node *head1,struct node *head2)
{
if (head1!=NULL && head2!=NULL)
{
if (head1->data == head2->data)
{
if (head1->left->data == head2->left->data)
{
return (isomorphic(head1>left,head2->left ) &&
isomorphic(head1>right,head2->right));
}
else if (head->left->data == head2->right->data)
{
return (isomorphic**(head1>left,head2->right)
&&(isomorphichead1>right,head2->left));
}
else
return (false);
}
}
else if (head1 == NULL && head2 == NULL)
return (true);
else
return (false);
}

On 10 June 2010 00:00, souravsain <souravs...@gmail.com> wrote:

>
> As per @Algoose's explanation, this can be found using the algorithm
> to comapre if 2 binary trees are equal (quite often asked and found in
> net). In this we generally go recursive and say
> T1 is equal to T2
> if T1=T2
> and same holds for T1-Left, T2-Left (recursive call on left tree)
> and same holds for T1-Right, T2-Right (recursive call on right tree).
>
> We can use the same and change the calls as
> if T1=T2
> and same holds for T1-Left, T2-Right (recursive call on left tree)
> and same holds for T1-Right, T2-Left (recursive call on right tree).
>
>
> Sain
>
> On Jun 9, 10:45 pm, saurabh gupta <sgup...@gmail.com> wrote:
> > is-isomorphic(t1, t2) {
> >      t1ld = t1->left->data
> >      t2ld = t2->left->data
> >     //.....
> >
> >     //base case for null or replace by sentinels and check
> >     if( t1ld == t2ld && t1rd == t2rd)
> >        return is-isomorphic(t1ld, t2ld) && return is-isomorphic(t1rd,
> t2rd)
> >     if (t1ld == t2rd && t1rd == t2ld)
> >        return is-isomorphic(t1ld, t2rd) && return is-isomorphic(t1rd,
> t2ld)
> >     return false;
> >
> >
> >
> >
> >
> > }
> > On Wed, Jun 9, 2010 at 8:29 PM, divya jain <sweetdivya....@gmail.com>
> wrote:
> > > @vadivel and anand
> >
> > > { 1,2,3 } is *isomorphic* to { 1,3,2 }
> > > { 1,2,3,4,5,6,7 } is *isomorphic* to { 1,3,2,7,6,4,5 }
> > > { 1,2,3,4,5,6,7 } is NOT *isomorphic* to { 1,3,2,4,5,6,7 }
> >
> > > so its nt necessary that right and left will interchange. it may or may
> > > not. if all right and left are interchanged then it is mirror tree. i
> think
> > > ur code is for mirror tree and not isomorphic tree..
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> <algogeeks%2bunsubscr...@googlegroups­.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > Man goes to doctor. Says he's depressed. Says life seems harsh and cruel.
> > Says he feels all alone in a threatening world where what lies ahead is
> > vague and uncertain. Doctor says "Treatment is simple. Great clown
> > Pagliacci is in town tonight. Go and see him. That should pick you up."
> Man
> > bursts into tears. Says "But, doctor...I am Pagliacci."- Hide quoted text
> -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to