adding break to first loop...just to avoid unnecessary iterations.
if (root->children[i]!=NULL)
{
flag=1;
break;
}
end for
On Wed, Dec 21, 2011 at 10:59 PM, atul anand <[email protected]>wrote:
> @shashank:
>
> yeah here is the algo , please me know if you find any bug:-
>
>
> node *Reverse(node *root,node *pre)
> {
> flag=0;
>
> for i=0 to n
> if (root->children[i]!=NULL)
> {
> flag=1;
> }
> end for
>
> if( ! flag)
> {
> add root to the list;
> return root;
> }
>
> for(i=0;i<n;i++)
> {
>
> pre=reverse(root->children[i],NULL);
>
> if(pre)
> {
> pre->children[i]=root;
> }
> }
>
> return root;
>
> }
>
>
>
>
> On Wed, Dec 21, 2011 at 1:08 PM, WgpShashank
> <[email protected]>wrote:
>
>> @atul,, yeah , but can you write some proper psuedo code/ Algorithm then
>> we can discus more about test cases.
>>
>> Thanks
>> Shashank
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/VPZpHM8D_WcJ.
>>
>> 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.