Homework Solution: The input is two sorted arrays. Each array has n elements. In total, there are 2n elemen…

    The input is two sorted arrays. Each array has n elements. In total, there are 2n elements. You can assume that all values in the arrays are distinct. A statistician asks you to find the nth order statistic of these values. The nth order statistic is the nth smallest value. a) Give a divide and conquer algorithm to find this value in asymptotic time Θ(log n). b) Argue why your algorithm is correct. c) Write down the running time recurrence, including the base case
    The input is two sorted arrays. Each array has n elements. In total, there are 2n elements. You can assume that all values in the arrays are distinct. A statistician asks you to find the n^th order statistic of these values. The n^th order statistic is the n^th smallest value. a) Give a divide and conquer algorithm to find this value in asymptotic time Theta (log n). b) Argue why your algorithm is correct. c) Write down the running time recurrence, including the base case

    Expert Answer

     
    Explanation:
    Instead of comparing the middle element of the arrays,

    The input is span as as as select attires. Each attire has n atoms. In entirety, there are 2n atoms. You can feign that integral treasures in the attires are independent. A statistician asks you to experience the nth ordain statistic of these treasures. The nth ordain statistic is the nth lowest treasure. a) Give a distribute and master algorithm to experience this treasure in asymptotic space Θ(log n). b) Argue why your algorithm is punish. c) Write down the general space return, including the grovelling condition

    The input is span as as as select attires. Each attire has n atoms. In entirety, there are 2n atoms. You can feign that integral treasures in the attires are independent. A statistician asks you to experience the n^th ordain statistic of these treasures. The n^th ordain statistic is the n^th lowest treasure. a) Give a distribute and master algorithm to experience this treasure in asymptotic space Theta (log n). b) Argue why your algorithm is punish. c) Write down the general space return, including the grovelling condition

    Expert Counter-argument

     

    Explanation:
    Instead of comparing the intermediate atom of the attires,
    we parallel the k / 2th atom.
    Let arr1 and arr2 be the attires.
    Now, if arr1[k / 2]  arr1[1]
    
    New subproblem:
    Attire 1 - 6 7 9
    Attire 2 - 1 4 8 10
    k = 5 - 2 = 3
    
    floor(k / 2) = 1
    arr1[1] = 6
    arr2[1] = 1
    arr1[1] > arr2[1]
    
    New subproblem:
    Attire 1 - 6 7 9
    Attire 2 - 4 8 10
    k = 3 - 1 = 2
    
    floor(k / 2) = 1
    arr1[1] = 6
    arr2[1] = 4
    arr1[1] > arr2[1]
    
    New subproblem:
    Attire 1 - 6 7 9
    Attire 2 - 8 10
    k = 2 - 1 = 1
    
    Now, we promptly parallel original atoms,
    since k = 1. 
    arr1[1] < arr2[1]
    Hence, arr1[1] = 6 is the counter-argument.
    
     
    

    Space Complexity: O(log k)

    Now, k can admit a utmost treasure of n + n. This instrument that log k can be in the worst condition, log(n + n).