explain modifide bubble sort code in java

Solutions on MaxInterview for explain modifide bubble sort code in java by the best coders in the world

showing results for - "explain modifide bubble sort code in java"
Cassia
23 Aug 2017
1void bubble(int a[], int n){
2	for(int i=0; i<n; i++){
3		int swaps=0;
4		for(int j=0; j<n-i-1; j++){
5			if(a[j]>a[j+1]){
6				int t=a[j];
7				a[j]=a[j+1];
8				a[j+1]=t;
9				swaps++;
10			}
11		}
12		if(swaps==0)
13			break;
14	}
15}