Question: I'm posting this question 2nd time. Because first time fake tutor answer totally wrong and irrelevant. kindly give me true solution as required Question 7:

I'm posting this question 2nd time. Because first time fake tutor answer totally wrong and irrelevant. kindly give me true solution as required
Question 7: Let n > 2 be an integer, and let Ali...n] be an array storing n pairwise distinct numbers. It is easy to compute the two smallest numbers in the array A: Using n-1 comparisons, we find the smallest number in A. Then, using n - 2 comparisons, we find the smallest number among the remaining n - 1 numbers. The total number of comparisons made is 2n - 3. By a similar argument, we can find the smallest and largest numbers in A using 2n -- 3 comparisons. In this question, you will show that the number of comparisons can be improved (7.1) Consider the following algorithm TwoSMALLEST(A,n), which computes the two smallest numbers in the array A: = Algorithm TWOSMALLEST(A.n): if A[1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
