Which parallel sorting algorithm has the best average case performance?

The following article (PDF download) is a comparative study of parallel sorting algorithms on various architectures: Parallel sorting algorithms on various architectures According to the article, sample sort seems to be best on many parallel architecture types. Update to address Mark’s concern of age: Here are more recent articles introducing something more novel (from 2007, … Read more

Data structures for loaded dice?

You are looking for the alias method which provides a O(1) method for generating a fixed discrete probability distribution (assuming you can access entries in an array of length n in constant time) with a one-time O(n) set-up. You can find it documented in chapter 3 (PDF) of “Non-Uniform Random Variate Generation” by Luc Devroye. … Read more

How does one make a Zip bomb?

Citing from the Wikipedia page: One example of a Zip bomb is the file 45.1.zip which was 45.1 kilobytes of compressed data, containing nine layers of nested zip files in sets of 10, each bottom layer archive containing a 1.30 gigabyte file for a total of 1.30 exabytes of uncompressed data. So all you need … Read more

Simple calculations for working with lat/lon and km distance?

The approximate conversions are: Latitude: 1 deg = 110.574 km Longitude: 1 deg = 111.320*cos(latitude) km This doesn’t fully correct for the Earth’s polar flattening – for that you’d probably want a more complicated formula using the WGS84 reference ellipsoid (the model used for GPS). But the error is probably negligible for your purposes. Source: … Read more

How does the Amazon Recommendation feature work?

It is both an art and a science. Typical fields of study revolve around market basket analysis (also called affinity analysis) which is a subset of the field of data mining. Typical components in such a system include identification of primary driver items and the identification of affinity items (accessory upsell, cross sell). Keep in … Read more

Why use Dijkstra’s Algorithm if Breadth First Search (BFS) can do the same thing faster?

Dijkstra allows assigning distances other than 1 for each step. For example, in routing the distances (or weights) could be assigned by speed, cost, preference, etc. The algorithm then gives you the shortest path from your source to every node in the traversed graph. Meanwhile BFS basically just expands the search by one “step” (link, … Read more