Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4) Let rand (n) be a library function that evaluates to a random integer in Z ea

ID: 3748171 • Letter: 4

Question

4) Let rand (n) be a library function that evaluates to a random integer in Z each time it is called (like Java's Random.nextInt (n)). Write a method called createRandomFunction (right here in your written homework) in C or Java that takes a positive integer as a parameter and returns an array with n elements each uniformly distributed in Z Essentially I'm asking you to write a method that specifies a random function Z" Zn using the table filling method (ie, a- createRandomFunction (10) fills a with random values and then a[o] would tell you what 0 maps to, a1] tells you what 1 maps to, etc.)

Explanation / Answer

public static int[] createRandomFunction(int n) { int[] arr = new int[n]; for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote