Rajib_119's blog

By Rajib_119, 10 years ago, In English

How can I find the 1000th permutation of 50!. Using Backtrack i can easily find the 100th permutation of 5! or 5th permutation of 3! which is 3 1 2.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Assume that you have to find the K-th permutation with N elements. With fixed first element you can rearrange the other elements in (N-1)! ways. Now you can easily find the first element in the K-th permutation. Then do the same with the second element, and then with the third and so on.

»
10 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

http://ideone.com/yP5KuJ

for understanding refer to Factorial number system Wiki page Complexity (n lg(n)^2 )