Solved

Posted on 2008-11-15

Hi, I want to find the closest set of coordinates in a plane. I'm reading 10 million different coordinates from a file. I need to determine which two are the closest ones. I have solved it using brute force by storing them into an array and simply comparing each coordinate to the rest. However since my input size is extremely big, this takes a while. I was looking at improving the run time. I wanted to ask you guys what would be the best way to do it...

Thanks.

Thanks.

3 Comments

I don't really understand the instructions above. Can someone please explain it Barney Style? Thank you.

array[array.length/2] would be the median if array was sorted left to right.

l would then be the coordinate of array[array.length/2] that was sorted on

> And my base case would be array.length ==2 that way i just compute the from coordinate 1 and coordinate 2?

sqrt( (X distance)^2 + (Y distance)^2 )

By clicking you are agreeing to Experts Exchange's Terms of Use.

Title | # Comments | Views | Activity |
---|---|---|---|

How to find Tomcat initial memory and Max memory through command line windows | 12 | 95 | |

Convert BufferedReader to File | 1 | 49 | |

array11 challenge | 16 | 40 | |

mapShare challenge | 13 | 40 |

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**11** Experts available now in Live!