The following algorithm sorts the numbers in the array from smallest to largest. The function pos_min(A,a,b) returns the

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The following algorithm sorts the numbers in the array from smallest to largest. The function pos_min(A,a,b) returns the

Post by answerhappygod »

The Following Algorithm Sorts The Numbers In The Array From Smallest To Largest The Function Pos Min A A B Returns The 1
The Following Algorithm Sorts The Numbers In The Array From Smallest To Largest The Function Pos Min A A B Returns The 1 (84.28 KiB) Viewed 30 times
The following algorithm sorts the numbers in the array from smallest to largest. The function pos_min(A,a,b) returns the position of the minimum value stored between positions a and b in the array, both inclusive. How can you modify it so the sorting is now done from largest to smallest? Please, do your own modification first (even better, code it!) and then, look at the possible answers. A: array of numbers N: number of elements in array A 1 2 3 function Sort(A,N) for 0 si < N-1 min=pos_min(A, i,N-1) swap(A, A[min]) end for end function 4 5 6 O change line 3 to min=pos_min(A, 0, i) and line 4 to swap(A[min], A) none of the others change line 2 to for N-1>=;>0 change line 3 to min=pos_min(A, 0, i) O change line 2 to for N-1>=i>0 and line 3 to min=pos_min(A, 0, i)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply