For example I have array:
int a[] = new int[]{3,4,6,2,1};
I need list of all permutations such tha if one is like this, {3,2,1,4,6}
, others must not be the same. I know that if the length of the array is n then there are n! possible combinations. How can this algortihm be written?
Update: thanks, but I need a pseudo code algorithm like:
for(int i=0;i<a.length;i++){
// code here
}
Just algorithm. Yes, API functions are good, but it does not help me too much.