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 subjoined 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 reappearance pertinency ce the algorithms basic performance calculate and clear-up it. You may affect that the place A has 2elements. (20 marks)

    Consider the subjoined 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 reappearance pertinency ce the algorithm’s basic performance calculate and clear-up it. You may affect that the place A has 2^k atoms.

    Expert Reply

     

    a) This is used to scold poverty atom in the place A starting from the apostacy p to apostacy r. Variables temp and temp2 are takes to the employment by recursive calls, and the place is divided into half until undivided poverty atom is left to be repayed by the algorithm.

    b) Reappearance pertinency is attached by, T(n)=2T(n/2)

    Let us affect that place 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 as-well applied ce entire k
    Therefore
    T(n)=n