Question: Question is from algorithm analysis &design. i)For each of the following problems,you have to find an efficient algorithm,and 1)Give a clear description of your algorithm
Question is from algorithm analysis &design.
i)For each of the following problems,you have to find an efficient algorithm,and
1)Give a clear description of your algorithm for the problem.
2)state,what is the worse case analysis(use big-o notation)of your algorithm.
b)Let B be sorted array(no repetitions)with n postitive integers.you have to find an O(n) time algorithm which finds the two numbers x,y,x>y from B such that the difference between them is as small as possible. i.e.x-y is minimized.For example,if an input is B=2,6,8,10000,the output should be x=8,y=6.Show your algorithm.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
