I was asked this question in a start-up's interview:
When we search in Google map, we type a string in the search bar and it takes to the location. In the map we can see places near by: like schools, colleges, hospital, stations etc.
How can we implement such a functionality?
Followup:
You are given a file with millions of lines. Each line consists of a tuple:
<string placename, double longitude, double latitude>
How will you implement a function to search by a particular place (given its name in string)? I was asked not to use a database.
I suggested using a quad tree for the first question where we divide the planet into uniform size grids. Each grid will have list of locations nearby.
For the follow up question I asked if the data can come in memory or not. In case it can come in memory, then I suggested creating a trie where each terminating node of a trie can store the list of nearby places.
Any better answers or suggestions to approach this question..