4 ms·
This reminded me of the card shuffling algorithm from Sedgewick http://algs4.cs.princeton.edu/lectures/21ElementarySorts.pdf http://algs4.cs.princeton.edu/lect
by damian2000 12y ago
This reminded me of the card shuffling algorithm from Sedgewick
http://algs4.cs.princeton.edu/lectures/21ElementarySorts.pdf http://algs4.cs.princeton.edu/lectures/21ElementarySorts.pdf
In that he assigns a random number to each element. Sorts the elements based on the random number. Then takes the first N elements from the beginning.