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

Please help me out with this one guys, I\'m completely lost. I am programming ot

ID: 3654236 • Letter: P

Question

Please help me out with this one guys, I'm completely lost. I am programming other projects also, please help. Much appreciated, Thanks guys. Chapter 7 PP # 4, page 563. Add a method bubbleSort to the class ArraySorter, as given in listing 7.10, that performs a bubble sort of an array. The bubble sort algorithm examines all adjacent pairs of elements in the array from the beginning to the end and interchanges any two elements that are out of order. Each interchange makes the array more sorted than it was, until it is entirely sorted. The algorithm in pseudocode follows: Repeat the following until the array a is sorted: for (index=0; index < a.length -1; index ++) if (a[index] > a[index + 1]) Interchange the values of a[index] and a[index +1]. The bubble sort algorithm usually requires more time than other sorting methods. ---------------------------------------------------------------------------------------------------------------------- This is the Code they give you on 7.10: public class ArraySorter { public static void selectionSort(int[] anArray) { for (int index =0; index < anArray.length -1; index++) { int indexOfNextSmallest = getIndexOfSmallest(index,anArray); interchange(index,indexOfNextSmallest, anArray); } } private static int getIndexOfSmallest(int startIndex, int[] a) { int min = a[startIndex]; int indexOfMin = startIndex; for(int index=startIndex + 1; index < a.length; index ++) { if(a[index] < min) { min = a[index]; indexOfMin=index; } } return indexOfMin; } private static void interchange(int i, int j, int[] a) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } }

Explanation / Answer

public class bubbleSort{ public static void main(String a[]){ int i; int array[] = {12,9,4,99,120,1,3,10}; System.out.println("Values Before the sort: "); for(i = 0; i