1 this is the standard quicksort algorithm let s assume thatthe partition function a 5346836

1.                 This is the standard Quicksort algorithm. Let’s assume thatthe Partition function always places the pivot element in thecenter. The call Quicksort (A, 1, A.length)sorts the whole array.

Quicksort (A, p, r)

           if p

               q ß Partition(A, p, r);

   Quicksort (A, p, q-1)

   Quicksort (A, q+1, r)

Wemodify the algorithm to find the kth smallest element in anarray.

int QuickFindk (A, p, r, k)

           if p

               q ß Partition(A, p, r);

                if ( q == k)

return A[q];

                           if (k

           returnQuickFindk (A, p, q-1,k)

     else

           returnQuickFindk (A, q+1, r,k)

Assume that Partition always places qin the middle.

(a)    Write the recurrence for this algorithm

(b)    Explain how the algorithm works

(c)    Solve the recurrence to find the complexityof finding the kth smallest element in an array/

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now