Your algorithm will never shuffle a deck of cards because randomly selecting a 64 digit means your N(logN) algorithm will need to generate on average the 2^63th or larger permutation. It’ll be several millennia for every deck shuffle. If you don’t believe me try to write it.
Also, I’m not really sure your nlog(n) algorithm claim is accurate - python’s itertools says that the time complexity to generate the Nth permutation is still N!. So for a 52 deck card on average you’re going to have to generate 2^88 permutations.
By comparison, shuffling is O(n) where your n is the number of items.
I don't know what you're talking about, and that makes two of us.
Writing the Nth-permutation is something I've done before as a leetcode challenge, here's example code [1]
Maybe python implements it poorly, but it can definitely be done in n-log(n), and also try researching a little more before you pick a disagreement. I'm sure a simple google search could have saved you the trouble.
Comments
The number of permissions of a deck of cards is 2^225 according to the article. Permissions grow quite quick
Yeah. So something like a 50-digit number. I guess your point is this would require a BigInt?
From a performance perspective it's negligible. Like when doing RSA for example the primes are usually 2^512 in length.
Your algorithm will never shuffle a deck of cards because randomly selecting a 64 digit means your N(logN) algorithm will need to generate on average the 2^63th or larger permutation. It’ll be several millennia for every deck shuffle. If you don’t believe me try to write it.
Also, I’m not really sure your nlog(n) algorithm claim is accurate - python’s itertools says that the time complexity to generate the Nth permutation is still N!. So for a 52 deck card on average you’re going to have to generate 2^88 permutations.
By comparison, shuffling is O(n) where your n is the number of items.
I don't know what you're talking about, and that makes two of us.
Writing the Nth-permutation is something I've done before as a leetcode challenge, here's example code [1]
Maybe python implements it poorly, but it can definitely be done in n-log(n), and also try researching a little more before you pick a disagreement. I'm sure a simple google search could have saved you the trouble.
---- 1 - https://stackoverflow.com/questions/7918806/finding-n-th-per...