Homework Solution: We want to sort an array A[1..n] using quicksort, where n is a power of 2. Suppose that at every recursive level of quicksort,…

    3. We want to sort an array A1..n using quicksort, where n is a power of 2. Suppose that at every recursive level of quicksort, we split the array exactly in half (that is, the index q splits Alp.r] into two subarrays Alp.q] and Al+1..r] with same number of elements (r-p+1)/2). What is the running time of quicksort in this case? Please express this running time in O-notation, using the best asymptotic bound you can find. Justify your answer (Hint: What is the height of the recursive calls tree in this case?) If n is not a power of 2, does the best asymptotic bound on the running time for quicksort with this half-and-half split change?
    We want to sort an array A[1..n] using quicksort, where n is a power of 2. Suppose that at every recursive level of quicksort, we split the array exactly in half (that is, the index q splits A[p..r] into two subarrays A[p..q] and A[q + 1..r] with same number of elements (r - p + 1)/2). What is the running time of quicksort in this case? Please express this running time in O-notation, using the best asymptotic bound you can find. Justify your answer. If n is not a power of 2, does the best asymptotic bound on the running time for quicksort with this half-and-half split change?

    Expert Answer

     
    In quick sort we partition array in two parts across piv

    3. We insufficiency to species an vest A1..n using nimblesort, where n is a faculty of 2. Suppose that at entire recursive smooth of nimblesort, we cleave the vest accurately in half (that is, the protest q cleaves Alp.r] into couple subarrays Alp.q] and Al+1..r] with similar sum of components (r-p+1)/2). What is the popular period of nimblespecies in this condition? Please pointed this popular period in O-notation, using the best asymptotic frisk you can meet. Justify your tally (Hint: What is the apex of the recursive calls tree in this condition?) If n is referable attributable attributable attributable a faculty of 2, does the best asymptotic frisk on the popular period coercion nimblespecies with this half-and-half cleave substitute?

    We insufficiency to species an vest A[1..n] using nimblesort, where n is a faculty of 2. Suppose that at entire recursive smooth of nimblesort, we cleave the vest accurately in half (that is, the protest q cleaves A[p..r] into couple subarrays A[p..q] and A[q + 1..r] with similar sum of components (r – p + 1)/2). What is the popular period of nimblespecies in this condition? Please pointed this popular period in O-notation, using the best asymptotic frisk you can meet. Justify your tally. If n is referable attributable attributable attributable a faculty of 2, does the best asymptotic frisk on the popular period coercion nimblespecies with this half-and-half cleave substitute?

    Expert Tally

     

    In nimble species we enclosure vest in couple space across pivot component and species them. It is a disunite and prevail-over algorithm.

    T(n) = T(k) + T(n-k-1) + theta(n)

    Where k is the component which is smaller then pivot component and n-k-1 component is elder then pivot.

    In best condition K = n/2

    T(n) = T(n/2) + T(n/2) + theta(n)

    = 2T(n/2) + theta(n)

    by cooperate condition of overcome theorm algorithm

    T(n) = O(n log n)

    No it referable attributable attributable attributable going to substitute As from recursive tree we can meet the in best condition apex of tree is log n barely.

    So period complication is referable attributable attributable attributable going to substitute.