Combinatorial algorithms for nearest neighbors, near-duplicates and small-world design