Homework Solution: Consider the following algorithm ALGORITHM Find (A[p.r]) if p = r return A[p] else temp 1 = Find (A[p.. (p + r)/2]) temp2 = F…

    3. Consider the following algorithm ALGORITHM FindA[p.r) if p ==r return A[p] else templ = Find(Aſp.L(P+r)/2] temp2 = FindAllpr) /2 |+1.r) if temple temp2 return temp1 else return temp2 a. What does this algorithm compute? b. Set up a recurrence relation for the algorithms basic operation count and solve it. You may assume that the array A has 2elements. (20 marks)
    Consider the following algorithm ALGORITHM Find (A[p.r]) if p = r return 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 return temp 1 else return temp 2 a. What does this algorithm compute? b. Set up a recurrence relation for the algorithm's basic operation count and solve it. You may assume that the array A has 2k elements.

    Expert Answer

     
    a. The algorithm is used to compute the minimum element in

    3. Consider the cethcoming algorithm ALGORITHM FindA[p.r) if p ==r come-back A[p] else templ = Find(Aſp.L(P+r)/2] temp2 = FindAllpr) /2 |+1.r) if meeting-house temp2 come-back temp1 else come-back temp2 a. What does this algorithm appraise? b. Set up a perching relevancy ce the algorithms basic performance estimate and work-out it. You may take that the equip A has 2elements. (20 marks)

    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.

    Expert Apology

     

    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.