Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Professor I. M. Nuts of the Math Department is scratching his head over the following problem. Given two sequences of numbers X=x1,,xn and Y=y1,,yn he
Professor I. M. Nuts of the Math Department is scratching his head over the following problem. Given two sequences of numbers X=x1,,xn and Y=y1,,yn he must find the mn largest values of the sums xi+yj,1i,jn in SORTED ORDER (smallest to largest). One may assume that mn but one must not assume that m is a constant. The proposed algorithm should have worst-case running time that is o(n2). He requests the assistance of the CS Department in dealing with this problem. (a) Give an algorithm whose worst-case running time is o(n2) that solves this problem; an (n2) time algorithm will not get you any points. (b) Does there exist an algorithm whose worst-case performance is (n) ? Explain, i.e. show/prove that such an algorithm does not exist or give the algorithm and analyze its performance, if such an algorithm exists. Example. If X=2,0,2,3,1,100,290,300,4 and Y=20,19,8,200,11,1,10,7,0 and m=3 then the answer is 301,310,311. Note that 301 can result either as the sum of 290+11 or 300+1
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