Permutation Sort Algorithm Very Slow

Ali GOREN via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 7 15:01:24 PDT 2014


Thank you. I can not resolve it in quicker time, right?

Also:

dlang online compiler and dpaste:

return code: 9 killed

why?

thank you

On Saturday, 7 June 2014 at 21:57:31 UTC, Chris Cain wrote:
> 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