Given n values to be sorted. 1. Write the general k-way SORT-MERGE algorithm kWayMergeSort(n, k, m)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given n values to be sorted. 1. Write the general k-way SORT-MERGE algorithm kWayMergeSort(n, k, m) so that it splits the input into k 2 partitions in each round down until each partition contains m < < n values and use insertion sort to sort each of the smallest parti- tions of size m. (Hint: take floor or ceiling of division. And use one array of size n to keep all partitions, but you must be careful how to handle the boundaries of each partition). Your algorithm should then merge k> 2 partitions in each round up until it gets back the n values together sorted. Assume n> (2 x k x m). 2. Show that your algorithm is loop invariant. 3. Implement your algorithm using any programming language of your choice. Test your program on your own data. Use three data sets in your testing, one small n = (4x kx m), one mid-size n> (100 x kx m) and one large n> (10000 x kx m), where k = 4 and m= 10 for the testing. 4. Capture and compare the actual computer run time of your program for each of the three datasets. Given n values to be sorted. 1. Write the general k-way SORT-MERGE algorithm kWayMergeSort(n, k, m) so that it splits the input into k 2 partitions in each round down until each partition contains m < < n values and use insertion sort to sort each of the smallest parti- tions of size m. (Hint: take floor or ceiling of division. And use one array of size n to keep all partitions, but you must be careful how to handle the boundaries of each partition). Your algorithm should then merge k> 2 partitions in each round up until it gets back the n values together sorted. Assume n> (2 x k x m). 2. Show that your algorithm is loop invariant. 3. Implement your algorithm using any programming language of your choice. Test your program on your own data. Use three data sets in your testing, one small n = (4x kx m), one mid-size n> (100 x kx m) and one large n> (10000 x kx m), where k = 4 and m= 10 for the testing. 4. Capture and compare the actual computer run time of your program for each of the three datasets.
Expert Answer:
Related Book For
Holt McDougal Larson Geometry
ISBN: 9780547315171
1st Edition
Authors: Ron Larson, Laurie Boswell, Timothy D. Kanold, Lee Stiff
Posted Date:
Students also viewed these programming questions
-
Jacob Bower has a liability that: Has a principal balance of $100 million on June 30, 2008, Accrues interest quarterly starting on June 30, 2008, Pays interest quarterly, Has a one-year term to...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
. 4. Bank overdrafts repayable on * 1 point demand may be included in the cash and cash equivalent balance. True O False
-
Consider the following information about three stocks: a. If your portfolio is invested 40 percent each in A and B and 20 percent in C, what is the portfolio expected return? The variance? The...
-
In Topic 1: Decision Analysis of Module 2, the importance of using the six steps to follow in decision making was discussed. In addition, as part of the theme, the criteria to be used in...
-
A solar collector design consists of an inner tube enclosed concentrically in an outer tube that is transparent to solar radiation. The tubes are thin walled with inner and outer diameters of 0.08...
-
The following operating information reports the results of McKinney Company's production and sale of 16,000 air-conditioned motorcycle helmets last year. Based on early market forecasts, McKinney...
-
Determine the x-y and n-t components of the 17.0 kip force F acting on the simply supported beam. Assume a 33 ft, b = 18 ft,0 = 20%, and = 45 y L--x A Answers: Fx = a C F b B i kips Fy= kips Fn =...
-
The AS Corporation (a hypothetical company) was formed and began operations on January 1, 2020, and is owned by Ann Smith, who owns 50% of the stock. There is one other shareholder who owns the rest...
-
Several prerequisites are necessary for marketing to occur. Identify each prerequisite in the following examples: (a) a politician running for political office, (b) a consumer seeking physical...
-
Improve the Die class of Chapter 6. Turn the generator variable into a static variable so that all dice share a single random number generator.
-
Look at the public interface of the java.lang.System class and discuss whether or not it is cohesive.
-
Implement a class Product. A product has a name and a price, for example new Product("Toaster", 29.95 ). Supply methods getName, getPrice, and reducePrice. Supply a program ProductPrinter that makes...
-
Your task is to design a general program for managing board games with two players. Your program should be flexible enough to handle games such as tic-tac-toe, chess, or the Game of Nim of Exercise...
-
Find the general solution of the differential equation: y' - 5y = xy. Use lower case c for the constant in answer.
-
g(x) = x 5 5x 6 a. Show that g(x) = 0 has a root, , between x = 1 and x = 2. b. Show that the equation g(x) = 0 can be written as x = (px + q) 1/r , where p, q and r are integers to be found. The...
-
In a dilation, the image is _?_ to the original figure.
-
For what value of x is the quadrilateral a parallelogram? 4x + 2 + 5x-6
-
Use the diagram at the right. You know that 1 4. What can you conclude? 2 4 3 S
-
Why is it important to test a theory? Why not simply accept a theory if it sounds right?
-
What is the intuition behind the geometric growth in interest?
-
You have $100,000 to donate to your college. You want to endow a perpetual scholarship that makes its first payment in 1 year. If the colleges discount rate is 4%, how large will the annual...
Study smarter with the SolutionInn App