4 ms·
Fisher-Yates was one of the first algorithms my CS course exposed me to; nicknamed the knuth shuffle, not 100% why but it is in TAOCP. I implement it relativel
by Normal_gaussian 7y ago
Fisher-Yates was one of the first algorithms my CS course exposed me to; nicknamed the knuth shuffle, not 100% why but it is in TAOCP.
I implement it relatively frequently (~once a year) as it is often quicker to write than find an implementation.
Surveying some peers I was very surprised to find they weren't aware of it!
- xxs 7y agoAlso known as card deck shuffle, but indeed I have always known it as Knuth. As for peers part, perhaps they use a library function - Java has java.util.Collections.shuffle. OTOH is a single line, provided the generator can produce a random number [0-n).
- vanderZwan 7y agoIIRC, Knuth made it famous (because TAOCP). Often with the naming of these things there is a misalignment with who discovered/published it first and who popularized it first. (I personally think naming the algorithm after both is a good compromise)