Question: Please fix this code so that it sequentially sorts the array from right to left numerically from least to largest and prints off each change

Please fix this code so that it sequentially sorts the array from right to left numerically from least to largest and prints off each change in the code this is a java program. I believe the method call to findPos needs to be edited as I don't have any code right now. The sorting algorithm is called

// Course: CPS 151 // Semester: 2022 Spring // Name: Josh Neils // Section: 2 // Assignment: Lab 2 // Purpose: Sorting a list of unsorted arrays. // Date completed: 1/20/2022

import java.util.Random;

public class cps151lab2 {

final static Random rand = new Random(); final static int MAX_SIZE = 10; // amount of storage for the intList static int size = 0; // number of values actually in the intList static int[] intList = new int[MAX_SIZE];

/** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("CPS 151 In-class assignment 2 by Josh Neils"); setRandom(intList, 100); printList(intList, MAX_SIZE, " Array before sorting: "); sort(intList); printList(intList, MAX_SIZE, " Array after sorting: "); } // end main

// prints partially filled array with a legend private static void printList(final int[] arr, final int size, final String legend) { System.out.println(legend); for (int k = 0; k

// move items from pos:size-1 one position down (higher subscripts) private static void shiftDown(int[] arr, int size, int pos) { for (int i= 0; iarr[j]) { pos=arr[i]; arr[i]=arr[j]; arr[j]=pos; } } } } // end shiftDown

private static void setRandom(int[] arr, final int range) { for (int k = 0; k

private static void sort(int[] arr) { for (int k = 1; k

// find the right place for item to be inserted within arr[0:size-1] private static int findPos(int[] arr, int size, int item) { return 0; // stub, keeps compiler happy } // end findPos }

The output should look something like this not exactly the same as .Random is used in this program please get back to me as soon as you can thankyou.

Please fix this code so that it sequentially sorts the array from

Output - ICA02_Key (run) X D run: ID CPS 151 In-class assignment 2 by KEY Array before sorting: 35 22 60 79 44 63 99 34 19 30 ; 2 After pass 1: 22 35 60 79 44 63 99 34 19 30 After pass 2: 22 35 60 79 44 63 99 34 19 30 After pass 3: 22 35 60 79 44 63 99 34 19 30 After pass 4: 22 35 44 60 79 63 99 34 19 30 After pass 5: 22 35 44 60 63 79 99 34 19 30 After pass 6: 22 35 44 60 63 79 99 34 19 30 After pass 7: 22 34 35 44 60 63 79 99 19 30 After pass 8: 19 22 34 35 44 60 63 79 99 30 After pass 9: 19 22 30 34 35 44 60 63 79 99 Array after sorting: 19 22 30 34 35 44 60 63 79 99 BUILD SUCCESSFUL (total time: 0 seconds)

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!