Question: Question 2 . You are given a sorted array A of n distinct integers, drawn from 1 to m where A 1 , 2 ,

Question 2. You are given a sorted array A of n distinct integers, drawn from 1 to m where A1,2,dots,mOAA2,3,5,7,8,10O(n)SnknkSSn.
That is,Ais a subset of1,2,dots,m. Implement anO(logn) time algorithm (i.e., write a function)to find
the smallest non-negative integer that is missing in A given as a parameter. For example, when Ais[1,
2,3,5,7,8,10], the function must return 4.
Question 3. Implement anO(n) algorithm that, given a set Sofn distinct numbers and a positive
integer kn, determines the k numbers inS that have the closest value to the median ofS.
 Question 2. You are given a sorted array A of n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!