You have the number group {1,2...n}, so naturally it has n! permutations, come up with an efficient algorithm (method) that can take any one of these permutations and assign it a number from 1 to n! (or 0 to (n!-1), whatever suits you), each permutation must have one and only 1 assigned number and no two permutationjs can be assigned the same number.
For example, if n=3 then you have 6 permutations, a possible way to number them is:
123 #0
132 #1
231 #2
213 #3
312 #4
321 #5
(of course your algorithm has to be more efficient than just coming up with all the permutations then numbering them and remembering their numbers)
Question
Guest
You have the number group {1,2...n}, so naturally it has n! permutations, come up with an efficient algorithm (method) that can take any one of these permutations and assign it a number from 1 to n! (or 0 to (n!-1), whatever suits you), each permutation must have one and only 1 assigned number and no two permutationjs can be assigned the same number.
For example, if n=3 then you have 6 permutations, a possible way to number them is:
123 #0
132 #1
231 #2
213 #3
312 #4
321 #5
(of course your algorithm has to be more efficient than just coming up with all the permutations then numbering them and remembering their numbers)
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.