[Chicago] Closest Index

Daniel Griffin dgriff1 at gmail.com
Sat Jan 5 00:01:17 CET 2013


You can keep partitioning A until you find whatever "close" means. Since A
is sorted you can keep splitting it in half until you find what you want.
If B is also sorted you could keep restricting where you search in A by the
position of the last thing you found in A.


On Fri, Jan 4, 2013 at 3:11 PM, 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<http://mail.python.org/mailman/listinfo/chicago>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20130104/94223ebc/attachment.html>


More information about the Chicago mailing list