hi,
I think we can use a stack here...
start from left of string(0 to n)
till we don't get a ')' we will keep on pushin the elements on the
stack...
if we encounter a '0' we will pop elements till ')' if this count is 2
everytime except the last time then this is a mirror tree else not....
i think this algorithm should work...
Thanks and regards,
Gajendra Dadheech
Software Engineer-I (R&D)
----------------------------------------
MediaTek India Technology
Work: 120-4343900(Ext. 276)
Mobile: +91-9540646145
-----------------------------------------
"Be the change you want to see in the world" -Mohandas Gandhi
On Sun, Feb 6, 2011 at 9:41 PM, jalaj jaiswal <[email protected]>wrote:
> @ bittu and bharath
>
> the tree is given in form of string
>
>
>
>
>
> On Sun, Feb 6, 2011 at 6:55 PM, Bharath M R <[email protected]>wrote:
>
>> bool visit(node temp1, node temp2)
>> {
>> if(temp1.left==null && temp2.right==null)
>> return true;
>> else if((temp1.left==null && temp2.right!=null) || (temp1.left!=null
>> && temp2.right==null))
>> return false;
>> else
>> return visit(temp1.left,temp2.right);
>>
>> -- do the same for temp1.right and temp2.left
>> }
>>
>> Just check whether root. left and root.right are not null and pass it the
>> visit function.
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> With Regards,
> *Jalaj Jaiswal* (+919019947895)
> Final Year Undergraduate,
> IIIT ALLAHABAD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.