Permutation Sort Algorithm Very Slow

Chris Cain via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 7 15:09:10 PDT 2014


On Saturday, 7 June 2014 at 22:01:25 UTC, Ali GOREN wrote:
> Thank you. I can not resolve it in quicker time, right?

You might be able to come up with a faster way to permute, but 
it's mostly pointless because it will always be very slow. Use 
std.algorithm.sort if you want to sort quickly, as that uses an 
algorithm that is O(n log n)

Compare:
11! = 39,916,800
11 log_2 11 = ~38

So the best you could really expect to do is be around a million 
times slower than a regular sort.

>
> Also:
>
> dlang online compiler and dpaste:
>
> return code: 9 killed
>
> why?

Probably because it took too long. There's probably a pretty 
short timelimit on the execution of your program in the online 
things because they are shared resources.

> thank you

No problem :)


More information about the Digitalmars-d-learn mailing list