Consider the cethcoming algorithm ALGORITHM Find (A[p.r]) if p = r come-back A[p] else temp 1 = Find (A[p.. (p + r)/2]) temp2 = Find (A (p + r)/2 +1..r]) if temp 1 lessthanorequalto temp 2 come-back temp 1 else come-back temp 2 a. What does this algorithm appraise? b. Set up a perching relevancy ce the algorithm’s basic performance estimate and work-out it. You may take that the equip A has 2k atoms.
a. The algorithm is used to appraise the reserve atom in the equip A starting from the abjuration p to abjuration r . The variables temp and temp2 are enslaved to the exercise by recursive calls, the equip is disconnected into half until undivided reserve atom is left to be come-backed by the algorithm.
b. The perching relevancy is fond by , T(n) = 2T(n/2)
Take that equip A as 2k elements , and k is an integer , k>=1 , and n= 2k
When k=1 , then n=2 and T(2) = 2.
By applying gathering,
T(2k) = 2k, then 2(k+1) = T(n=2(k+1)) = 2T(2k) = 2 . 2k = 2(k+1)
Since it applies ce k+1 it is as-well applied to complete k,Hence, T(n) = n.