Question: Consider the following recursive algorithm C(i, j, x) that checks whether the array segment A[i..j] contains key x, where i lessthanorequalto j. It return YES

 Consider the following recursive algorithm C(i, j, x) that checks whether

Consider the following recursive algorithm C(i, j, x) that checks whether the array segment A[i..j] contains key x, where i lessthanorequalto j. It return YES if x is found and NO otherwise (note that floor(x) is the floor function that returns the largest integer that is less than or equal to x): C(i, j, x) if i=j then if A[i] = x return YES else return NO else if C(i, floor((i + j)/2), x) = YES return YES else return C(floor((i + j)/2) + 1, j, x) Consider the following recursive algorithm C(i, j, x) that checks whether the array segment A[i..j] contains key x, where i lessthanorequalto j. It return YES if x is found and NO otherwise (note that floor(x) is the floor function that returns the largest integer that is less than or equal to x): C(i, j, x) if i=j then if A[i] = x return YES else return NO else if C(i, floor((i + j)/2), x) = YES return YES else return C(floor((i + j)/2) + 1, j, x)

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!