[Chicago] Closest Index

sheila miguez shekay at pobox.com
Sat Jan 5 16:21:06 CET 2013


I have naive questions.

How did A get constructed? If an example of integers in A is
1,1,2,3,3,3 is it a list of that, or a counter 2,1,3 or something
else? What is the distribution of A? When you do the work do you have
to construct A every time or will it live around for a while?


On Sat, Jan 5, 2013 at 7:13 AM, Oren Livne <livne at uchicago.edu> wrote:
> Thanks so much to all of you! I can sort B and sweep through both arrays
> once, as suggest.
> Oren
>
>
> On 1/4/2013 5:20 PM, Rajesh Sankaran wrote:
>>
>> What about sorting B ( cost - O(nlog(n)))?  Once sorted, as you advance in
>> B array, your A pointer will only move forward.
>> You will go through each of the two arrays only once (cost O(m+n)).
>>
>> --
>> Raj
>>
>> On Fri, 04 Jan 2013 16:11:25 -0600, Oren Livne <livne at uchicago.edu> wrote:
>>
>>> Dear All,
>>>
>>> I have an sorted array A of size 3.4M of positive integers and an array B
>>> of size 300,000 of positive integers. I would like to output for each x in B
>>> the value in A that is closest to it. This is easy to do for a single
>>> element, but I need an efficient implementation for the entire of B. Any
>>> suggestions?
>>>
>>> Thanks,
>>> Oren
>
>
>
> --
> A person is just about as big as the things that make him angry.
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago



-- 
sheila


More information about the Chicago mailing list