There are many different instructions to do random permutation on the Internet, but they all use libraries. Is there any way to do random permutation without using any built-in library? I know how to generate random numbers using Math.random(). Does generating random permutation have to do with Math.random()? Shuffling looks so complicated to me.
My goal is if I run the programme by 'java randompermutation 3', then the programme returns either 1,2,3 or 1,3,2, or 3,1,2, or 3,2,1, or 2,3,1, or 2,1,3
One algorithm for sorting an array is based on selection sort and is called selection shuffle. Go through the array and for each index, pick a random index following it and swap those two indices. Since this looks a bit like homework, I will refrain from giving any actual code, but this is a solution.