Question: For a particular 'n' value, the maximum value (m) for any element in the array would be: max ValueFactor *n, where max ValueFactor (an

For a particular 'n' value, the maximum value (m) for any element in the array would be: max ValueFactor *n,

For a particular 'n' value, the maximum value (m) for any element in the array would be: max ValueFactor *n, where max ValueFactor (an integer) ranges from 1, 2, 3, 10. For example, if n = 100, the maximum value (m) for any element in the array could be: 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000. **** You are given a startup code that should be run for a particular array size (n) input by the user and it runs 1000 iterations (maxIterations = 1000) for a particular value of the max ValueFactor (corresponding to a particular value of m), generating 1000 different arrays and determining whether each of them is unique or not (through a function find Uniqueness to be implemented by you). The code in the main function takes care of adding the number of comparisons encountered for all the 1000 arrays in the form of a variable called totalComp. After running the max Iterations, the code will print the values of max ValueFactor and average number of comparisons per array size. Tasks: (1) Implement the function findUniqueness for a given array and array size, and return the number of comparisons encountered to check for uniqueness for the particular array. (2) For the two array size values assigned to you, plot the max ValueFactor vs. average number of comparisons per array size in a single plot. Interpret your observations, including answers to the following questions: (a) For a given array size, does the average number of comparisons increase with the maximum value for any element in the array? (b) For a given m (i.e., maximum value for any element in the array), does the average number of comparisons increase with array size?

Step by Step Solution

3.38 Rating (145 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets start by implementing the findUniqueness function and then move on to the main code The function will take an array and its size as input and ret... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!