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> > > . > > 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. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.