Question: 1. Given k sorted lists Li, L2,..,Lk of/k numbers each with 1 s k s n, design a divide-and- conquer algorithm to sort all n

1. Given k sorted lists Li, L2,..,Lk of"/k numbers each with 1 s k s n, design a divide-and- conquer algorithm to sort all n numbers in the k sorted lists. Your algorithm should run in O(n log k) time (instead of O (n log n) time) (20 points) Note: 0 points will be given for this problem if your algorithm is not based on the divide-and conquer technique. 2. Let A[1 n] and B[1 n] be two arrays, each containing n numbers already sorted in the increasing order. Design an O (log n) time algorithm to find the median of all 2n elements in A and B. (The median of the 2n elements is the n-th smallest element.) (20 points) 3. In the SELECTION algorithm we studied in class, the input numbers are divided into groups of five. Will the algorithm still work in linear time if they are divided into groups of seven? Explain your answer. (20 points) 4. Let A[1... n] be an array of n numbers and let M be another number. Design an O(n) time algorithm to find the largest number x of A such that the sum of all numbers of A less than x is at most M, i.e., aEA,a a M. For simplicity, you may assume no two numbers in A are equal. (20 points 5. Here is a generalized version of the selection problem, called multiple selection. Let A[1... n] be an array of n numbers. Given m integers k1, k2, ..., km, with 1 S ki
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
