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);