Consider the following recursive algorithm C(i, j, x) that checks whether the array segment A[i..j] contains key x, where i = j. It return YES if x is found and NO otherwise (note that floor(x) is the...

Consider the following recursive algorithm C(i, j, x) that checks whether the array segment A[i..j] contains key x, where i = 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 thenif A[i] = xreturn YESelsereturn NOelseif C(i, floor((i+j)/2), x) = YESreturn YESelse return C(floor((i+j)/2) + 1, j, x)Let t(n) be the worst case time for C(1, n, x) and assume that n is a power of 2. (a) Give a recurrence for t(n). Don’t forget the initial condition; and (b) solve t(n) using the following methods: iteration, recursion tree, and the masters method. No credit will be given if your recurrence is incorrect.

May 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here