|
|
|
|
|
by TacticalCoder
698 days ago
|
|
I really enjoyed TFA but this: > Technically, you could get extremely unlucky: at each step, you could pick the largest element as your pivot. Each step would only remove one element from the list and you’d actually have O(n2) performance instead of O(n) If adversarial input is a concern, doing a O(n) shuffle of the data first guarantees this cannot happen. If the data is really too big to shuffle, then only shuffle once a bucket is small enough to be shuffled. If you do shuffle, probabilities are here to guarantee that that worst case cannot happen. If anyone says that "technically" it can happen, I'll answer that then "technically" an attacker could also guess correctly every bit of your 256 bits private key. Our world is build on probabilities: all our private keys are protected by the mathematical improbability that someone shall guess them correctly. From what I read, a shuffle followed by quickselect is O(n) for all practical purposes. |
|