Homework Solution: Consider the following algorithm ALGORITHM Find(A[p..r]) if p == r return A[p] else temp1 = Find(A[p….

    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 temp1 = Find(A[p..[(p + r)/2]] temp2 = Find(A[[(p + r)/2] + 1..r]) if temp1 lessthanorequalto temp2 return temp1 else return temp2 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 2^k elements.

    Expert Answer

     
    a) This is used to compute minimum element in the array A starting from the

    3. Consider the aftercited algorithm ALGORITHM FindA[p.r) if p ==r repay A[p] else templ = Find(Aſp.L(P+r)/2] temp2 = FindAllpr) /2 |+1.r) if habitation temp2 repay temp1 else repay temp2 a. What does this algorithm scold? b. Set up a repose aspect ce the algorithms basic production estimate and explain it. You may presume that the vest A has 2elements. (20 marks)

    Consider the aftercited algorithm ALGORITHM Find(A[p..r]) if p == r repay A[p] else temp1 = Find(A[p..[(p + r)/2]] temp2 = Find(A[[(p + r)/2] + 1..r]) if temp1 lessthanorequalto temp2 repay temp1 else repay temp2 a. What does this algorithm scold? b. Set up a repose aspect ce the algorithm’s basic production estimate and explain it. You may presume that the vest A has 2^k parts.

    Expert Repartee

     

    a) This is used to scold restriction part in the vest A starting from the condemnation p to condemnation r. Variables temp and temp2 are takes to the discharge by recursive calls, and the vest is separated into half until individual restriction part is left to be repayed by the algorithm.

    b) Repose aspect is dedicated by, T(n)=2T(n/2)

    Let us presume that vest A as 2k elements and k is an integer, k>1, and n=2k

    if k=1, ten n=2 and t(n)=2

    By using induction
    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 also applied ce perfect k
    Therefore
    T(n)=n