Question: ( 1 0 pts ) Design recursive algorithm Where ( A , p , r , x ) , by simulating binary search, that takes

(10 pts) Design recursive algorithm Where (A, p, r, x), by simulating
binary search, that takes a sorted array A[p] through A[r] of distinct
positive integers in increasing order, a positive integer x that is not
present in A, and returns two values that indicate where in A integer
x belongs. In particular, if x < A[p], the algoithm return p, p. If
x > A[r] the algorithm returns r, r. Otherwise, it returns i, i +1 such
that A[i]< x < A[i +1]. You may use the notation return (x, y) to
return two values. For example, if A[p] A[r] had 1022253237
and x =27, then the algorithm returns p+2, p+3. If x =50, it returns
r, r. When invoked as Where (A,1, n, x), your algorithm must run in
O(log n) time. Present a complete algorithm in pseudocode form

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 Programming Questions!