Question: a) Given a sorted array of distinct integers A[1, ..., n], you want to find out whether there is an index i for which, A[i]

a) Given a sorted array of distinct integers A[1, ..., n], you want to find out whether there is an index i for which, A[i] = i. Give a divide and conqure algorithm in pseudocode that runs in O(log n).

b) Given a sorted array B, suppose that p and q are two elements of B. Design a divide and conqure algorithm to compute the number of elements between p and q (let p q). what is the running time of your algorithm?

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!