Let's say i create a String array that store 4 Alphabets {"A","B","C","D"}
How can i get the result if i need permutation of 4P3 and 4P2?
I had refer to many examples from the internet, but those examples cannot compute n selection from m elements. They only able to computer permutation of m elements without selection e.g. 4P4.
Hence i need guideline in how to compute this kind of permutation.
If i use manual calculation of 4P3 formula i get following result:
A B C
A B D
A C B
A C D
A D B
A D C
B A C
B A D
B C A
B C D
B D A
B D C
C A B
C A D
C B A
C B D
C D A
C D B
D A B
D A C
D B A
D B C
D C A
D C B
If i use manual calculation of 4P2 formula i get following result:
A B
B A
A C
C A
A D
D A
B C
C B
B D
D B
C D
D C
I need help in how to create an algorithm that can perform permutation of n selection from m elements.
Any enlighten/help will be appreciate.