Keep a pointer list1 at the beginning of one of the lists, and call the
function below on the other list.
int reverseCheck(NODE *p)
{
list2=p;
if(list2->next==NULL)
return;
reverseCheck(list2->next);
if(list2->next->data==list1->data)
list1=list1->next;
else
flag=0;
return flag;
}
On Wed, Jun 23, 2010 at 6:00 PM, divya jain <[email protected]>wrote:
> if we dont want to change original list..
> is there ny efficient method for that?
>
>
> On 23 June 2010 06:49, ANUJ KUMAR <[email protected]> wrote:
>
>> reverse one of the linked lists in O(n) time and then see if the
>> resulting one is same as the other one
>>
>> On Wed, Jun 23, 2010 at 1:56 AM, divya <[email protected]> wrote:
>> > Two link lists are given ...check if one is reverse of other. Do it
>> > without using extra space.
>> >
>> > --
>> > 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]<algogeeks%[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]<algogeeks%[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]<algogeeks%[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.