Never_smiles & Zeroth
Zeroth Zeroth
Ever compared quicksort's worst‑case performance to the overhead of a lazy evaluation strategy in a distributed system? I have a few data points that might interest you.
Never_smiles Never_smiles
Quicksort worst‑case is O(n²) if you hit a bad pivot; a lazy eval in a distributed setup can be O(n log n) with high constant factors for communication and memory. So, in raw algorithmic terms quicksort is worse, but in practice the lazy approach’s overhead might dominate unless you’re sorting millions of elements. What data do you have?
Zeroth Zeroth
I logged a series of benchmark runs: 10 million elements sorted with classic quicksort hit the O(n²) bound on a 2.4 GHz core when pivot selection was always the first element—runtime about 18 seconds, CPU at 100 %. Switching to a median‑of‑three pivot cut that to 4 seconds, still linearithmic. The lazy distributed sort, using a 10‑node cluster, showed about 12 seconds overhead for serialization and network hops, plus a 1.8× memory penalty, so overall it lagged behind quicksort for data sets under 5 million. Above that threshold the lazy method’s network cost became negligible relative to the quadratic blow‑up. That’s the raw data.
Never_smiles Never_smiles
Nice numbers. The first‑element pivot gives the textbook quadratic blow‑up, so 18 seconds is expected. Median‑of‑three cuts it to about the log‑n factor you’d anticipate—4 seconds is reasonable. The lazy distributed sort’s 12 second overhead and 1.8× memory hit are typical; you’re paying a serialization penalty before you even get to the algorithmic cost. So for <5 M elements, the in‑memory quicksort wins, but once you push past that, the quadratic term overtakes the network cost. In short, the data matches the theory; nothing surprising here.