user3806720
user3806720

Reputation: 19

How search in a list of coordinate in efficient way

I'm tring to use a efficient way to search if one Coordinate (that is not in arrys) is in arrays of coordinates. I wouldn't read the entire arrays I would a better solution. Anyone can help me?

Upvotes: 0

Views: 94

Answers (1)

Jason Baker
Jason Baker

Reputation: 2481

As Chief Two Pencils commented, this only works if you have some kind of ordering principle on your array. There are lots of good data types you could use to help you with this: Range trees, Quadtrees, and k-d Trees are a few that spring to mind.

If you can't change the structure of your data, you still have options. I can imagine an algorithm where you filter by x-coordinate, and then filter those by y-coordinate, and the performance wouldn't even be terrible.

Upvotes: 1

Related Questions