1for (int i = 0; i < arr.length; i++) {
2 for (int j = 0; j < arr.length-1-i; j++) {
3 if(arr[j]>arr[j+1])
4 {
5 int temp=arr[j];
6 arr[j]=arr[j+1];
7 arr[j+1]=temp;
8 }
9 }
10 System.out.print("Iteration "+(i+1)+": ");
11 printArray(arr);
12 }
13 return arr;
14// BUBBLE SORT
1A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of element in the respective data structure.