Nearest Neighbour (NN) is an intuitive method for finding a similar item.
In the recent past I kept stumbling on NN at work, quora and at coursera course. So here us an implementation in c++ to find nearest neighbour using a data structure called KD Tree on a 2-D Plane.
Here is the github gist:
References:
http://en.wikipedia.org/wiki/K-d_tree
I had actually implemented the above for a K-Nearest Neighbour, using a priority queue. you can all see that it only takes a minor tweak to achieve that.