Hello I have list of 1000 elements with duplicates and if I want to get all the permutations of the them after removing the duplicates then what would be the best and most mathematically efficient way of doing so.
Random rand = new Random();
for (int i = 0 ; i < 1000 ; i ++) {
list.add(i,rand.nextInt(500));
}
With above we get an array of 1000 elements and there will be duplicate elements too. What is a better way to print the permutations so that it consumes less memory space and less time.
I have worked with the Recursive Permutation algorithm but it takes time for values of n > 15 and also after a point an exception is thrown heap memory overflow.
Will something this be better, http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle