3 ms·
I guess I did not describe it fully enough - to assign randomly, you end up noticing that you don't want to waste time checking for slots you already assigned.
by Tichy 17y ago
I guess I did not describe it fully enough - to assign randomly, you end up noticing that you don't want to waste time checking for slots you already assigned. So the logical solution is to shrink the array by swapping out the randomly chosen index - basically the "good knuth". If you don't have an uninterrupted streak of cells to assign, you end up doing wasteful checks. Can't think of another way, off the top of my head.