Partial kNN algorithm