Question: 3. (5 points) Write two functions one to sort an integer array in descending, i.e, large to small, order and the other to another array

 3. (5 points) Write two functions one to sort an integer

3. (5 points) Write two functions one to sort an integer array in descending, i.e, large to small, order and the other to another array in descending order. Sorting is done by implementing the selection sort algorithm in Chapter 7 (see below for hints) with minor merge two arrays and store them in modification, i.e., search for the index of the largest element instead of the smallest. You cannot use the C* Ibrary function sort Then you will write a test driver, ie, the mainO function that reads in two integer arrays of maximum size 10 from the console and then outputs the merged array, which contains the sorted numbers, using the two functions created above. The sorted array will be of maximum size 20. You should be able to change the maximum size of the arrays by changing only one globally defined constant. Hint on selection sort: The array is imaginarily divided into two subarrays: the sorted one and unsorted one. Let the length of the array be len. Initially, the sorted subarray is empty and the unsorted subarray contains the whole array. The selection sort iterates through the following steps with array indices from 0 to (len-1), using i to store the index: i. ii. Find out the largest array element from i to (len-1) and use 1g to store the index of the largest number. b) 9 c) Swap the array[i] with array[1g] at this point, the sorted part contains from array[0] to array[1 ], and the unsorted from array( 1+1] to array[len-1] i. e) ifi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!