Implemented the knn search with a totally recursive function, according to Stanford CS106's pseudocode