Question
Suppose you are given a new hardware device that can merge k > 2 different sorted lists of total size n into a single sorted
Suppose you are given a new hardware device that can merge k > 2 different sorted lists of total size n into a single sorted list in O(n) time, independent of the value of k. Such a device could, for example, be based on a hardware streaming system or could be based on a network protocol. Show that you can use this device to sort items efficiently by answering the following. (3.a) Suppose that you are given k sorted lists where list i has length ni with m= S ni. Design and analyze an efficient algorithm to sort the m items using the hardware device, i.e., your algorithm uses the hardware device as a method call mergeKlists(L[][], k, m) to sort the m items, where L is a k X m twodimensional array containing a total of m items and L[i] contains a sorted list of length ni. Function mergeKlists() returns a 1-d sorted array of length m. What is the input size of this problem? What is the output-size of this problem? What are the time and space complexities of your algorithm? (3.b) Suppose now that you are given a list of n items (unordered). Show that you can use the hardware device to sort n elements in O(n log n / log k) time. Notice that, if k is (n), then you can use this device to sort in linear time. Obviously, your algorithm will use method calls mergeKlists() judiciously. What is the input size of this problem? What is the output-size of this problem? What are the time and space complexities of your algorithm?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started