Part II – Write a method that will produce random permutations of the numbers 1 to 10. To generate a random permutation, you need to fill an array with the numbers 1 to 10 so that no two entries of the array have the same contents.
One Idea: You could do it by brute force, by calling [login to view URL]() until it produces a value that is not yet in the array. That may take some time, and wouldn’t be efficient. Instead you should implement a smarter process.
Another Idea: Make a second array and fill it with the numbers 1 to 10, then pick one of those at random, remove it from the values you are picking from in the second array and append it to the permutation array. Repeat this 10 times.
Create a main method that will test this method along with a
printArray(int [] arr) method to print it out. Print out 5 or 6 arrays in your main method created by your randomizing method to ensure it is working appropriately.
Use comments to outline your logic for solving this problem.
Methods
main
printArray(int [] arr)
permutation(int[] arr)
the output is suppose to look like this:
[10, 1, 7, 6, 4, 8, 9, 2, 5, 3]
[3, 2, 8, 7, 1, 6, 10, 4, 9, 5]
[5, 9, 3, 8, 2, 6, 7, 1, 4, 10]
[7, 5, 3, 9, 8, 2, 4, 1, 10, 6]
[10, 6, 4, 9, 7, 1, 8, 5, 3, 2]
java file permutation is a code that works but not the way professor wants it
java file permutation1 is the format the way should it should be done