News for hackers. Stuff that matters.
Re:Virtual deck of cards using just a browser by teraflop on Tuesday June 01, 2021 @09:47PM (#27363851)
Maintaining a "pile" of not-yet-selected items, and randomly removing elements from it, turns your shuffle from an O(n) algorithm into an O(n^2) one (unless you go out of your way to use a more sophisticated data structure than either an array or a linked list).

It's not likely to matter much if you're only shuffling 52 cards, but if you're writing a general-purpose shuffle algorithm, there's no reason to needlessly make it inefficient.

There are no comments on this comment yet.