Re:Efficiency is dangerous and slowing down makes life better
by Retric on Friday August 21, 2020 @03:41PM
(#24238180)
Plenty of n log n operations are in constant space. Average Quicksort performance being perhaps the classic example. But most often you see these kinds of improvements by simply removing steps. Net result is less code, less memory use age, less of everything.
Re:Efficiency is dangerous and slowing down makes life better
by hansvm on Friday August 21, 2020 @04:07PM
(#24238404)
Yep, I'm not arguing that it's always a good idea (or even usually...or even that I've seen it be a good idea in the wild), just that it could be. Taking quicksort as an example, it's only constant space if you're allowed/able to mutate in-place. If you need (for some bizarre reason) to stream sorted results in constant space without mutating the underlying data then you'll need some other tool.
Hopefully not nitpicking too much: it's a win without _many_ tradeoffs. E.g., in the usual places where you'd accidentally get an O(n^2) operation rather than O(n log(n)), the O(n^2) operation is constant-space. In a sufficiently anomalous computing environment with a low enough priority on fast results you might still consciously opt for the O(n^2) solution.