📜 ⬆️ ⬇️

Benchmark testing and quick analysis of permutations algorithms

I’m hoping to improve intercommunication, which I’m hoping to improve.

image I urge you to reply this language in English, even you have some difficulties with this language. I am not writing a letter. However, I am going to talk about some poetical issues. - of course, about combinatorics and especially about generating objects. I mean permutations. If you’re always having fun, you’re always having to go on it. Kicked some habrausers up to write some code (see comments) and me too. This is where the event leads to.

I’m just skilled in the c89:
')
  1. Johnson-Trotter algorithm
  2. Naryana algorithm
  3. Algorithm taken from this habrpost , developed by Mrrl (A. Astrelin)

All the algorithms mentioned above are not recursive.

My version of Johnson-Trotter algorithm is not the best, I think. Nevertheless, it is up to show you how it produces for n = 10.

Time with console output (means printf)
real 1m19.410s
user 0m31.899s
sys 0m36.253s

Time without console output
real 0m2.241s
user 0m2.236s
sys 0m0.004s

My verstion of Mrrl code

With console output
real 1m11.565s
user 0m27.429s
sys 0m32.997s

Without console output
real 0m0.489s
user 0m0.486s
sys 0m0.002s

The last Naryana like algorithm gives such result

With console output
real 1m10.223s
user 0m8.617s
sys 0m38.165s

Without console output
real 0m0.453s
user 0m0.449s
sys 0m0.004s

Thanks for reading. I used this site for spell checking. Of course, you have been asked to ask me where you want the quick analysis ?! At this moment I can’t give you a simple answer. Maybe these three code-scripts should not be tuned, if it is possible. It is a quick and easy way to read pseudocode (reading description mostly). If I’m not mistaken, I’m publishing a version of the algorithm.

Source: https://habr.com/ru/post/433118/


All Articles