(Solved):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. Give an O(log n)- time algorithm for findin… View Answer…

 

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 one integer in this range missing from A. Give an O(log n)- time algorithm for finding the integer in this range that is not in A.

(a) Give the algorithm pseudocode

(b) Justify your big-Oh.

 

EXPERT ANSWER

(a) Binary search is a fast search algorithm with run-time complexity of O(log n).

Scroll to top