Question: what is the time complexity? static void bubblesort ( int [ ] arr ) { int n = arr.length; for ( int i = 0

what is the time complexity?
static void bubblesort(int[] arr){
int n = arr.length;
for (int i =0; i < n -1; i++){
System.out.print(arr[i]+":\t ");
for(int j=1; j <(n-i); j++){
System.out.print(arr[j]+",");
if (arr[j-1]> arr[j]){
int temp = arr[j-1];
arr[j-1]= arr[j];
arr[j]= temp;
}
}
System.out.println();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!