Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java: Write a JAVA program that reads a positive integer n (no less than 4) and produces 10 random permutations of the numbers 1

In Java:

image text in transcribed

image text in transcribed

image text in transcribed

Write a JAVA program that reads a positive integer n (no less than 4) and produces 10 random permutations of the numbers 1 to n. To generate a random permutation, you need to fill an array with the numbers 1 to n so that no two entries of the array have the same contents. You could do it by brute force, by calling Random.nextInt until it produces a value that is not yet in the array. Instead, in this lab assignment, you should implementa smart method. Make a second array and fill it with the numbers 1 to n. Then pick one of those at random, remove it, and append it to the permutation array You need to complete the implementation of classes PermutationGenerator and MyListoperations and use them in the main ) method. class PermutationGenerator int maxnum; / permutation is for numbers maxnum PermutationGenerator (int n) maxnum = n; // generate a random permutation of numbers 1maxnunm // return a permutation array which stores a random permutation int[l generate ( // array for a random permutation int permutation[] = new int [maxnum); // numbers not yet in a permutation int second [ ] = new int [maxnum); // your code comes here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions