Question: Suppose you are given a sorted array, A, of n distinct integers in the range from 1 to n + 1, so there is exactly

Suppose you are given a sorted array, A, of n distinct integers in the range from 1 to n + 1, so there is exactly one integer in this range missing from A. Describe an O(log n)-time algorithm for finding the integer in this range that is not in A.

Step by Step Solution

3.37 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

We can use binary search to find the missing integer in Olog n time We can compare the midpo... View full answer

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 Data Structures Algorithms Questions!