(Total: 100 points)1.Let X(1..n) and Y(1..n) contain two lists of n integers, each sorted in nondecreasingorder. Give the best (worst-case complexity) algorithm that you can think for finding(a)the largest integer of all 2n combined elements.(b)the second largest integer of all 2n combined elements.
Get answer to your question and much more
(c)the median (or the nthsmallest integer) of all 2n combined elements.
Get answer to your question and much more
For instance, X = (4, 7, 8, 9, 12) and Y = (1, 2, 5, 9, 10), then median = 7, the nthsmallest,inthecombinedlist(1,2,4,5,7,8,9,9, 10, 12).[Hint: use the conceptsimilar to binary search]
Get answer to your question and much more
2.1-to-2 PARTITION:Instance: A finite set of positive integersZ= {z1, z2, ... , znQuestion: Is there a subsetZ'ofZsuch thatSum of all numbers inZ'= 2*Sum of all numbers in(a)Obtain the dynamic programming functional equation to solve the 1-to-2PARTITIONproblem.}.Z-Z'
Get answer to your question and much more