We say that an array A[1..n] is k-sorted if it can be divided into k blocks,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
We say that an array A[1..n] is k-sorted if it can be divided into k blocks, each of size n/k, such that the elements in each block are larger than the elements in earlier blocks, and smaller than elements in later blocks. The elements within each block need not be sorted. For example, the following array is 4-sorted: 1 2 4 3 7 6 8 5 10 11 9 12 15 13 16 14 (a) (10 pts) Write down the pseudocode for an algorithm that completely sorts an already k-sorted array of n elements in O(n log(n/k)) time. Write down the pseudocode, analyze its running time and explain why it correctly sorts a k-sorted array. (b) (20 pts) Prove that any comparison-based algorithm to completely sort a k-sorted array requires (n log(n/k)) comparisons in the worst case, i.e., that your algorithm in part (a) is asymptotically optimal? Hint: It is not sufficient to combine lower bounds to sort individual blocks! Think about how many different permutations are possible in a k-sorted array. (c) (OPTIONAL - 0 pts) Prove that any comparison-based algorithm requires at least n(n log k) compar- isons in the worst-case to k-sort an unsorted array of n elements. Can you design an algorithm that k-sorts an unsorted array that runs in O(n log k) time? Activate Windows We say that an array A[1..n] is k-sorted if it can be divided into k blocks, each of size n/k, such that the elements in each block are larger than the elements in earlier blocks, and smaller than elements in later blocks. The elements within each block need not be sorted. For example, the following array is 4-sorted: 1 2 4 3 7 6 8 5 10 11 9 12 15 13 16 14 (a) (10 pts) Write down the pseudocode for an algorithm that completely sorts an already k-sorted array of n elements in O(n log(n/k)) time. Write down the pseudocode, analyze its running time and explain why it correctly sorts a k-sorted array. (b) (20 pts) Prove that any comparison-based algorithm to completely sort a k-sorted array requires (n log(n/k)) comparisons in the worst case, i.e., that your algorithm in part (a) is asymptotically optimal? Hint: It is not sufficient to combine lower bounds to sort individual blocks! Think about how many different permutations are possible in a k-sorted array. (c) (OPTIONAL - 0 pts) Prove that any comparison-based algorithm requires at least n(n log k) compar- isons in the worst-case to k-sort an unsorted array of n elements. Can you design an algorithm that k-sorts an unsorted array that runs in O(n log k) time? Activate Windows
Expert Answer:
Answer rating: 100% (QA)
a Heres the pseudocode for an algorithm that completely sorts an already ksorted array of n elements in Onlognk time kSortSortA n k if k 1 SortA Sort the entire array using a comparisonbased sorting a... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these operating system questions
-
91. A higher-priced mortgage is a covered transaction with an APR that exceeds the average prime offer rate (APOR) for a comparable transaction as of the date of the interest rate is set by what...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A compare-exchange operation on two array elements A[i] and A[j], where i < j, has the form COMPARE-EXCHANGE (A, i, j) 1 If A[i] > A[j] 2 exchange A[i] with A[j] After the compare-exchange operation,...
-
Classify each protein example according to its highest level of protein structure. Primary structure the amino acid sequence of myoglobin Secondary structure a single helical chain of collagen Answer...
-
What are home health care agencies?
-
Go to your librarys website. Find the librarys location of one AICPAs reference books. If your library does not have it, suggest where you should go to view this important research tool and explain...
-
Clemente Company manufactures bicycles and tricycles. For both products, materials are added at the beginning of the production process, and conversion costs are in- curred uniformly. Production and...
-
The mean per capita daily water consumption in a village in Bangladesh is about 83 liters per person and the standard deviation is about 11.9 liters per person. Random samples of size 50 are drawn...
-
Current Attempt In Progress Sunland Company has a materials price standard of $2.00 per pound. 6300 pounds of materials were purchased at $2.20 a pound. The actual quantity of materials used was 6300...
-
Enter a lookup function in cell E5 that returns the tax deduction amount for the number of dependents listed in the cell C5. Use the table in range H13:I17 to complete the function. The maximum...
-
The bonds used to compute this curve are all zero-coupon bonds, with a face value of $1,000. About how much would you expect to pay today for a five-year, zero coupon Treasury Bond?
-
would mary be justified in ignoring this situation particularly since she is not the purchasing agent? in preparing your answer consider the standards of purchasing practice
-
The final script of the project should be talking about the Fair Credit Reporting Act (fcra). Each student has the task of creating an infomercial video and accompanying script/storyboard based on an...
-
Your career as a Victim Advocate has changed since 2001 with the increase in school shootings, hate crimes, and domestic terrorism. The February 26, 1993, bombing of the World Trade Center (the first...
-
The report has to be composed in an excel file format composing both the summary and replication parts in Sheet 1 and Sheet 2 of the same file. Part 1 (Summary) 1. Executive Summary: A brief summary...
-
The fair price of an insurance policy that completely compensates Kat in the event of an accident is
-
A 0 . 6 5 0 kg mass is held at rest against a linear spring that is compressed by 0 . 0 7 0 m . The spring force pushes on the mass in the + x direction and the mass is on a horizontal surface. a )...
-
Use the method of Example 4.29 to compute the indicated power of the matrix. 1 0 1
-
Show that the solution of T(n) = T(n=2) + 1 is O(lg n).
-
Prove that if G is an undirected bipartite graph with an odd number of vertices, then G is nonhamiltonian.
-
This problem examines three algorithms for searching for a value x in an unsorted array A consisting of n elements. Consider the following randomized strategy: pick a random index i into A. If A[i] =...
-
The headquarters of Hill Crest Corporation, a pri- vate company with $15.5 million in annual sales, is located in California. Hill Crest provides for its 150 clients an online legal software service...
-
Transferring people from job to job within the organization is the philosophy at Arcadia Plastics. Management feels that job rotation deters employees from feeling that they are stagnating in their...
-
Gustave, CPA, during its preliminary review of the financial statements of Comet, Inc., found a lack of proper segregation of duties between the programming and operating functions. Comet owns its...
Study smarter with the SolutionInn App