Permutation Sort Algorithm Very Slow
Chris Cain via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 7 14:57:29 PDT 2014
On Saturday, 7 June 2014 at 21:40:08 UTC, Agora wrote:
> Why is running slow?
One of the main reasons is because the number of permutations an
array has is n!. Thus the expected runtime is O(n!). That's a
slow, slow algorithm in general. In particular, your array with
length 11 has 39,916,800 permutations (although it, obviously,
doesn't have to go through *all* of those to get the sorted
sequence in this case).
More information about the Digitalmars-d-learn
mailing list