Saturday, 7 September 2013

Set up a recurrence relation for the algorithm¡¯s basic operation count and solve it

Set up a recurrence relation for the algorithm¡¯s basic operation count
and solve it

Consider the following algorithm
ALGORITHM Find(A[0..n©\1])
if n ==1 return A[0]
else temp = Find(A[0..n©\2])
if temp ¡Ü A[n©\1] return temp
else return A[n©\1]
a. What does this algorithm compute?
b. Set up a recurrence relation for the algorithm¡¯s basic operation count
and solve it.
Does this algo return A[0],A[0..3],A[0..5],A[0.7],A[0..8], perhaps for
n=9? Am I on the right track?
Appreciate if someone could give me along! Thanks!

No comments:

Post a Comment