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 Pseudocode for an algorithm that completely sorts a ksorted array of n elements in Onlognk time Algorithm SortKSortedArrayA n k 1 Divide the array A into k blocks each of size nk 2 Sort each block u... 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
-
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 Blue Cross and Blue Shield plans? What benefits are provided by each plan?
-
Audrey Flet, the bookkeeper of ALN Co., was scheduled to leave on a three- week vacation at 5:00 on Friday. She couldnt get the companys trial balance to balance. At 4:30, she decided to put in...
-
The Racial Divide The website http://vallandingham.me/racial_divide/\#pt uses data from the US Census to visualize where whites and blacks live in different cities. Figure 2.98 gives a heat map of...
-
Read the paragraph in Appendix A, note 1, under item 3.RATIONALIZATION CHARGES. The paragraph describes a series of business decisions made by Home Depot to close some of its stores, including 15...
-
Hyrdo Billboard Company entered into an angreement to display billboard advertising for Adele Incorporated for 1 0 months for a $ 6 4 , 0 0 0 fixe fee. The agreement also includes a potential $ 6 , 5...
-
Healthwise Medical Supplies Company is located at 2400 Second Street, City, ST 12345. The company is a general partnership that uses the calendar year and accrual basis for both book and tax...
-
Consider Prob. 3. If the mapping X- X' given by z f is surjective, show that X must be a Hilbert space.
-
Confidence level is 99%, is not known, and the dotplot of a sample of 40 values of professional baseball player salaries is as shown below. Assume that we want to construct a confidence interval. Do...
-
Confidence level is 90%, is not known, and the dotplot of IQ scores of 20 randomly selected statistics instructors is as shown below. Assume that we want to construct a confidence interval. Do one...
-
In general a histogram is skewed to the left when the median is greater than the mean and to the right when the median is less than the mean. There are exceptions, however. Consider the following...
-
Figure Q28.23 shows a standing de Broglie wave. a. Does this standing wave represent a particle that travels back and forth between the boundaries with a constant speed or a changing speed? Explain....
-
Figure Q28.20 shows the standing de Broglie wave of a particle in a box. a. What is the quantum number? b. Can you determine from this picture whether the "classical" particle is moving to the right...
-
Application 3 to chapter 15nsuggests increased health care expenditures will crowd out other expenditures. What component of GDP do you think will suffer? Using that same argument, Nebraska is again...
-
You are standing at x = 9.0 km and your assistant is standing at x = 3.0 km. Lightning bolt 1 strikes at x = 0 km and lightning bolt 2 strikes at x = 12.0 km. You see the flash from bolt 2 at t = 10...
-
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] =...
-
Which of the following is not an important function of heterochromatin formation? a. Gene silencing b. Prevention of viral proliferation c. Splicing of pre-mRNA d. Prevention of movement of...
-
If the VIN3 gene had a loss-of-function mutation, how do you think that would affect the phenotypes of summer-annual and winter-annual Arabidopsis plants? a. Neither type would flower. b. Both types...
-
The effects of paramutation may vary with regard to a. the likelihood that the parmutagenic allele will alter the paramutable allele. b. the stability of the paramutagenic allele over the course of...
Study smarter with the SolutionInn App