Hacker News new | ask | show | jobs
by zamalek 1280 days ago
Collision detection in games. This problem is O(n^2) because you have to check every object against every other object.

You can almost only check objects that inhabit the same buckets (there are caveats, usually neighboring buckets are also checked), eliminating objects that couldn't possibly collide by virtue of e.g. being on the other side of the map. Of course this is still O(n^2) because every object could be in the same bucket (but that's unlikely).