Python shuffle algorithm performance

I was interested to learn about the time complexity of a shufflefunction in a randomPython library / module . Is it O (n) or is it smaller than this?

Is there a website that shows the time complexity of functions belonging to Python libraries?

+9
source share
1 answer

You cannot shuffle the list completely randomly less than O (n).

The implementation random.shuffle()uses the Fisher-Yates shuffle algorithm , which is easy to see O (n).

+14
source

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


All Articles