4 ms·
Hoare's original paper from 1962. http://comjnl.oxfordjournals.org/content/5/1/10.full.pdf+html http://comjnl.oxfordjournals.org/content/5/1/10.full.pdf+htm...
by brudgers 12y ago
Hoare's original paper from 1962.
http://comjnl.oxfordjournals.org/content/5/1/10.full.pdf+html http://comjnl.oxfordjournals.org/content/5/1/10.full.pdf+htm...
There are reasons not to perform quickSort the way people did fifty years ago. Data sets are larger and worst case time for quickSort approach 0(n^2) when data is already ordered and pivots are selected in-order. Randomizing pivot selection mitigates this back toward O(log n).
All that mutation and pointer swapping are artifacts of the way things used to have to be done by programmers. And they're useful as academic exercises. Hoare's algorithm is really fucking brilliant. But mapping and filtering in a functional style, makes more sense than dotting the 'i's and 'j's if someone is going to be reading and maintaining the code. There's a reason people don't use C to program mobile devices.
Moreover, while Hoare's original algorithm was designed to work in place, the idea of working in place is less coherent today. When we strive to distribute and parallelize big nasty resource intensive jobs, what does "in-place" mean? See Leslie Lamport, Thinking for Programmers at about time = 36:00
http://channel9.msdn.com/Events/Build/2014/3-642 http://channel9.msdn.com/Events/Build/2014/3-642
And even on a non-distributed system, when are we really coming up against the bounds of 'fast memory' these days? A serious problem that stretches 16 GigaBytes of RAM is less than $10,000 from 64 GigaBytes...or $200 from an SSD and using 'slow memory'.
Of course if we are parallelizing, we can even do it on one machine and again, what is 'in-place'? The caches? Again which ones and at what level. The Swift code (or Java or C#) may look like C, but it's not. It may be garbage collected, JIT'd, byte coded, and micro-coded all before it hits the mulit-stage branch predicting pipeline from several levels of cache reading from code pages that may have gone in and out to disk as threads and tasks switch.
'Place' might just mean somewhere. But probably somewheres.