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

Write a program that implements a method that receives an arrayparameter and sor

ID: 3618119 • Letter: W

Question

Write a program that implements a method that receives an arrayparameter and sorts that array using the bubble-sort algorithm. Thebubble-sort algorithm makes several passes through the array. Oneach pass, successive neighboring pairs are compared. If a pair isin decreasing order, its values are swapped: otherwise, the valuesremain unchanged. The technique is called a bubble sort because thesmaller values gradually "bubble" their way to the top.

The algorithm may be described as follows:

booleanchanged;

do{

changed =false;

for(int i = 0;i < list.length - 1; i++){

   if(list[i] > list[i + 1]){

      swaplist[i] with list[i + 1];
      changed = true;
    }
}
}while(changed);

Explanation / Answer

please rate - thanks import java.util.*; public class bubblesort {public static void main(String[] args)    {int i,j;     Scanner input = new Scanner(System.in);     Random gen = newRandom();                int num[]=newint[20];                                //array has 20 elements         for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote