merge sort both lists: O(nlogn)
Now, for both lists to be identical, just compare the corresponding elements
in the lists i.e. L1(1) == L2(1), L1(2) == L2(2) ...
=> O(n)

--Sundeep.


On Wed, Jun 2, 2010 at 10:47 PM, Raj N <rajn...@gmail.com> wrote:

> @Antony: The 2 lists should have the same elements as well the number must
> be equal
>
>
> On Wed, Jun 2, 2010 at 5:38 PM, Antony Vincent Pandian.S. <
> sant...@gmail.com> wrote:
>
>> @Raj
>>
>> What do you mean by identical? You are just concerned about the
>> presence of one element in another LL or you are concerned about the
>> equality of number of elements too?
>>
>> On 6/2/10, Raj N <rajn...@gmail.com> wrote:
>> > @sharad kumar: But don't you think this'll consume a lot of space. Merge
>> > sort will give O(nlogn) complexity when a separate LL is used to store
>> the
>> > sorted elements but if we disbuild the same LL it'll be >O(n2). And also
>> wat
>> > do u mean by combining LL can u explain
>> >
>> >
>> > On Wed, Jun 2, 2010 at 6:48 AM, sharad kumar <aryansmit3...@gmail.com
>> >wrote:
>> >
>> >> @Raj:sorting can be done in O(nlogn)..sort both and compare both.or use
>> a
>> >> hash map to store all elements of one LL and then compare it with
>> >> other....or combine both the  LL perform merge sort and start deleting
>> >> adjacent elements.if adjacent elements in equal count then LL are equal
>> >> and
>> >> at end of process we get an empty list.....
>> >>
>> >>
>> >> On Tue, Jun 1, 2010 at 11:55 PM, Raj N <rajn...@gmail.com> wrote:
>> >>
>> >>> Hi all,
>> >>> Can someone suggest an efficient algorithm to check if 2 linked lists
>> >>> are identical. If 2 lists have to be sorted then there'll be a lot of
>> >>> space consumption for 2 separate linked lists. Can the whole process
>> >>> be done < O(n2)
>> >>>
>> >>> --
>> >>> 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<algogeeks%252bunsubscr...@googlegroups.com>
>> >
>> >>> .
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/algogeeks?hl=en.
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> yezhu malai vaasa venkataramana Govinda Govinda
>> >>
>> >>  --
>> >> 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<algogeeks%252bunsubscr...@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<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> Sent from my mobile device
>>
>> Luv,
>> S.Antony Vincent Pandian
>>
>> --
>> 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<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