Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class SortingProgram { public static void main(String[] args) { //Array U

ID: 3653658 • Letter: P

Question

public class SortingProgram { public static void main(String[] args) { //Array Used in Bubble sort: eArray //Array Used in Selection sort: sArray //Array Used in Insertion sort: iArray int eArray[]={26,45,56,12,78,74,39,22,5,90,87,32,28,11,93,62,79,53,22,51}; int sArray[]={26,45,56,12,78,74,39,22,5,90,87,32,28,11,93,62,79,53,22,51}; int iArray[]={26,45,56,12,78,74,39,22,5,90,87,32,28,11,93,62,79,53,22,51}; //***********Bubble sort starts here: int temp; System.out.println("Original order:"); for(int num:eArray) System.out.print(num+", "); int swaps=0; for(int i=0; i eArray[j]){ temp = eArray[i]; eArray[i] = eArray[j]; swaps ++; eArray[j] = temp; } } } System.out.println(" Bubble Sorted:"); for(int num:eArray) System.out.print(num+", "); System.out.println(); System.out.println("Number of location swaps: " + swaps); //***********selection sort logic starts here: //Showing ArrayElements again below for better visibility. //eArray[]={26,45,56,12,78,74,39,22,5,90,87,32,28,11,93,62,79,53,22,51}; System.out.println(" Original order:"); for(int num:sArray) System.out.print(num+", "); temp=0; swaps= 0; for(int i=0; i<(sArray.length-1)-i; j++) { if(sArray[j] > sArray[j+1]) { temp = sArray[j]; sArray[j] = sArray[j+1]; sArray[j+1] = temp; swaps ++; } } } System.out.println(" Selction Sorted:"); for(int num:sArray) System.out.print(num+", "); System.out.println(); System.out.println("Number of location swaps: "+swaps); //***********Insertion sort logic starts here: //Showing ArrayElements again below for better visibility. //iArray[]={26,45,56,12,78,74,39,22,5,90,87,32,28,11,93,62,79,53,22,51}; System.out.println(" Original Order :"); for(int num:iArray) System.out.print(num+", "); temp=0; swaps=0; for(int i=1;i 0) && (iArray[j-1] >= temp)) { //until element is smaller. iArray[j] = iArray[j-1]; //shift them to right j--; //Move one position left } iArray[j] = temp; swaps=0; } System.out.println(" Insertion Sorted:"); for(int num:iArray) System.out.print(num+", "); System.out.println(); System.out.println("Number of location swaps: "+swaps); } }

Explanation / Answer

Please post formatted code. you code unreadable.