Landmarks Web App (ITA Archived Puzzle, Analyzed)
Contents
1 Problem Statement
Please refer to the landmarks web app problem on this page.
2 Analysis
The key part to solve here is to pick the nearby landmarks. As such we need to define what nearby means. Since each landmark’s latitutde and longitude are defined, we can define for a given landmark lm, whose latitude and longitude are l{m}_{lat} and l{m}_{long} respectively; a nearby landmark nlm with latitude and longitude nl{m}_{lat} and nl{m}_{long} such that:
The nearest
OR
The nearest
OR
The nearest
OR
The nearest
In other words, the nearest landmark in any direction to the given landmark assuming the given landmark as a center. If we can now think of a landmkark as a vertex on a graph, then the neighboring vertexes of a given landmark will be those landmarks that satisfy the above defintion.
3 Algorithm
Build a B-Tree where key is latitude and another where key is longitude. Now do a inorder traversal of this BTree while adding a landmark as a key to a hash table and its nearest landmarkes as values. Then given a landmark, we just look up in the hash table to find the nearest landmarks.
4 Implementation
In order to make the web application responsive, it would be nice to load the page with a javscript hashtable of landmarks and its nearby landmarks.