Which of the following function chooses a random index as the pivot? A. int Median(arr, left, right) { int mid; mid = (left + right)/2 if (arr[right] ...


Which of the following function chooses a random index as the pivot?


A. int Median(arr, left, right)


{


    int mid;


    mid = (left + right)/2


    if (arr[right] <>


        Swap(arr, left, right); //to swap arr[left],arr[right]


    if (arr[mid] <>


        Swap(arr, mid, left);//to swap arr[left],arr[mid]


    if (arr[right] <>


        Swap(arr, right, mid);// to swap arr[right],arr[mid]


    return mid;


}



B. int Median(arr, left, right)


{


    int mid;


    mid = (left + right)/2


    if (arr[right] > arr[left]);


        Swap(arr, left, right); //to swap arr[left],arr[right]


    if (arr[mid] <>


        Swap(arr, mid, left);//to swap arr[left],arr[mid]


    if (arr[right] <>


        Swap(arr, right, mid);// to swap arr[right],arr[mid]


    return mid;


}



C. int Median(arr, left, right)


{


    int mid;


    mid = (left + right)/2


    if (arr[left] <>


        Swap(arr, left, right); //to swap arr[left],arr[right]


    if (arr[left] <>


        Swap(arr, mid, left);//to swap arr[left],arr[mid]


    if (arr[right] <>


        Swap(arr, right, mid);// to swap arr[right],arr[mid]


    return mid;


}



D. intMedian(arr, left, right)


{


    int mid;


    mid = (left + right)/2


    if (arr[right] <>


        Swap(arr, left, right); //to swap arr[left],arr[right]


    if (arr[left] <>


        Swap(arr, mid, left);//to swap arr[left],arr[mid]


    if (arr[mid] <>


        Swap(arr, right, mid);// to swap arr[right],arr[mid]


    return mid;


}



Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here