How to remove duplicates based on a key in Mongodb?

This answer is obsolete : the dropDups option was removed in MongoDB 3.0, so a different approach will be required in most cases. For example, you could use aggregation as suggested on: MongoDB duplicate documents even after adding unique key. If you are certain that the source_references.key identifies duplicate records, you can ensure a unique index … Read more

Why is the “start small” algorithm for branch displacement not optimal?

Here’s a proof that, in the absence of the anomalous jumps mentioned by harold in the comments, the “start small” algorithm is optimal: First, let’s establish that “start small” always produces a feasible solution — that is, one that doesn’t contain any short encoding of a too-long jump. The algorithm essentially amounts to repeatedly asking … Read more

How could I speed up my written python code: spheres contact detection (collision) using spatial searching

UPDATE: this post answered is now superseded by this new one (which take into account the updates of the question) providing an even faster code based on a different approach. Step 1: better algorithm First of all, building a k-d tree runs in O(n log n) time and doing a query runs in O(log n) … Read more