3 ms·
That has expected running time N! loops. Far from horrible unless you make the 'is sorted' or 'randomize' calls horrible. The great thing about this algorithm
by rocqua 8y ago
That has expected running time N! loops. Far from horrible unless you make the 'is sorted' or 'randomize' calls horrible.
The great thing about this algorithm is that the same piece of code does all these things. There isn't a separate bodge for checking whether something is sorted.