Imagine a dataset of all the restaurants in the US (similar to Yelp, etc), how would you return a set of restaurants within a certain range of a particular zip code. (Assuming you have already a function, distanceBetweenZipCodes, which figures out the distance for you.)
The brute force method would be
For each restaurant in restaurantsInUSA if(distanceBetweenZipCodes(restaurant.zipcode, user.zipcode) < walkingDistance) save restaurant
However, it seems fairly inefficient to include New York restaurants in the search if the user is in California. But, it is possible that a restaurant is located close to a state line so segmenting the data by state would be problematic. You get the same problem if trying to segment by counties, cities or any other administrative boundary.
What would be the most appropriate way to segment the data to avoid having to check each and every record for all searches?