For a particular 'n' value, the maximum value (m) for any element in the array would...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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? 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?
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Essentials Of Modern Business Statistics With Microsoft Office Excel
ISBN: 9781337298353
7th Edition
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams
Posted Date:
Students also viewed these programming questions
-
If the power plant uses a Carnot cycle and the desired theoretical efficiency is 6.5%, from what depth must cold water be brought? (a) 100 m; (b) 400 m; (c) 800 m; (d) deeper than 1000 m. Ocean...
-
In ancient days a tribe of natives on the mythical continent of Atlantis was able to produce two commodities to eat. They could harvest fish from the sea and they could grow a form of wild oats.Table...
-
A sales invoice included the following information: merchandise price, $12,000; terms 1/10, n/eom, FOB shipping point with prepaid freight of $900 added to the invoice. Assuming that a credit for...
-
Suppose the balance sheets of a corporation for two years reported these figures: The notes to the 2017 financial statements report that because of some refinancing arrangements, the corporation was...
-
Are all audits the same? Why might an audit change from year to year?
-
Explain why the billing function should be segregated from credit granting, cash collection, and accounting.
-
The following financial information pertains to Sleepy Company: Required a. Prepare all the necessary journal entries for 2012 sales, collections, and write-offs (using the direct write-off method)....
-
The company has the following fixed costs: Product A, $613,000, Product B, $1,023,000, and common fixed costs of $372,800. Using the above information answer the following questions. What is the...
-
Ethyl alcohol (ethanol) can be produced by the fermentation of sugars derived from agricultural products such as sugarcane and corn. Some countries without large petroleum and natural gas...
-
Consider the language L = {a": n is not a perfect square}. * (a) Show that this language is not regular by applying the pumping lemma directly. (b) Then show the same thing by using the closure...
-
A cart of mass 2m rolls on a horizontal surface without friction. The cart is connected to a rigid wall by a spring of stiffness k. A disc of radius R and mass m rolls on the cart without slipping....
-
Consider the truss below. Determine the force in each member of the truss using the method of joints and state if the members are in tension or compression. -2 m B 30 kN -2 m E 30 kN -2 m 2m 40 kN...
-
A Fig. P8.3 8.3 An overhanging W920 x 449 rolled-steel beam supports a load Pas shown. Knowing that P = 700 kN, a = 2.5 m, and = 100 MPa, determine (a) the maximum value of the normal stress in the...
-
9.29 A capillary-tube flowmeter is being constructed to measure the flow rate of water. The glass tubing has an inside diameter of 1.50 mm and the pressure taps are located 0.35 m apart. (a) Estimate...
-
Fig. P8.1 10 ft D IP 8.1 A W10 x 39 rolled-steel beam supports a load P as shown. Knowing that P = 45 kips, a = 10 in., and 6 = 18 ksi, determine (a) the maximum value of the normal stress 6, in the...
-
Ireland Corporation obtained a $48,000 note receivable from a customer on June 30, 2021. The note, along with interest at 5%, is due on June 30, 2022. On September 30, 2021, Ireland discounted the...
-
What are the typical record-at-a-time operations for accessing a file? Which of these depend on the current file record?
-
Employee retention is a major concern for many companies. A survey of Americans asked how long they have worked for their current employer (Bureau of Labor Statistics website, December 2015)....
-
In January the U.S. unemployment rate dropped to 8.3% (U.S. Department of Labor website, February 10, 2012). The Census Bureau includes nine states in the Northeast region. Assume that the random...
-
1. The probability that a random customer does not purchase any of the three products (bread, jelly, or peanut butter). 2. The probability that a random customer purchases white bread. 3. The...
-
What are the PMI and PRINCE2?
-
What are the differences between a framework, a methodology and a standard?
-
Individually identify what you consider to be the greatest achievements accomplished by human kind in the last decade. Now share your list with other students in the class and come up with an...
Study smarter with the SolutionInn App