@ Wladimir

How do you get

(1,3)
(2,1)
(3,6)
(4,5)
(5,2)
(6,3)

B'cos once you sort the array you lose its original index.


On Tue, Dec 28, 2010 at 5:50 AM, Wladimir Tavares <[email protected]>wrote:

> Consider your example:
>
>
> One is
>
> 2 5 1 6 4 3
>
> other is
>
> 1 2 3 4 5 6.
>
>
> After sorted the first array and keep the position you will have:
>
>
> (1,3)
> (2,1)
> (3,6)
> (4,5)
> (5,2)
> (6,3)
>
> O(n log n)
>
> for each value of the second array do  a binary search in the first array
> and discover the position
>
> O (log n)
>
> O (nlgn + lgn)
>
>
>
> On Tue, Dec 28, 2010 at 8:48 AM, Bhoopendra Singh <[email protected]
> > wrote:
>
>> Is second array sorted?
>>
>>
>> On Tue, Dec 28, 2010 at 1:57 PM, juver++ <[email protected]> wrote:
>>
>>> Sort first array preserving the initial position of the elements.
>>>
>>> --
>>> 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.

Reply via email to