A give an algorithm that takes olog n time to find an i


Let A be an array of size n of integers, where A[1]

(Note that each entry may be a positive or negative integer.)

(a) Give an algorithm that takes O(log n) time to find an i such that A[i] = i, provided such an i exists. If no such i exists, the algorithm returns 0.

(b) Prove that any algorithm to solve this problem using comparisons must take time Ω(log n).

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: A give an algorithm that takes olog n time to find an i
Reference No:- TGS02178294

Now Priced at $10 (50% Discount)

Recommended (92%)

Rated (4.4/5)