Give a big-Oh characterization, in terms of n, of the running time for the following code below

icon
Related questions
Question

Give a big-Oh characterization, in terms of n, of the running time

for the following code below 

1
2
3
4
50
6
7
8
9
LO
11
L2
L3
14
15
L6
29
import java.util.Arrays;
30
31
32
33
34
public class buublesort {
public static void bubblesort (int[] arr)
{
}
35 }
36
int length = arr.length;
int temp;
for (int i=0;i<length-1; i++)
{
L7
L8
19
20
21
22
23
24
25
}
26 public static void main(String[] args)
27 (
28
for (int j = 0; j<length-1-i; j++)
{
if (arr [j+1] <arr[j])
{
}
temp = arr[j+1];
arr [j+1]=arr[j];
arr[j] =temp;
}
}
System.out.println("pass:" +(i+1) + "" + Arrays.toString(arr));
int[] arr (5,3,8,9,1,7,0, 2, 6, 4);
System.out.println("before bubble sorting:" + Arrays.toString (arr));
bubblesort (arr);
System.out.println("after bubble sorting: "+ Arrays.toString(arr));
1
-
Transcribed Image Text:1 2 3 4 50 6 7 8 9 LO 11 L2 L3 14 15 L6 29 import java.util.Arrays; 30 31 32 33 34 public class buublesort { public static void bubblesort (int[] arr) { } 35 } 36 int length = arr.length; int temp; for (int i=0;i<length-1; i++) { L7 L8 19 20 21 22 23 24 25 } 26 public static void main(String[] args) 27 ( 28 for (int j = 0; j<length-1-i; j++) { if (arr [j+1] <arr[j]) { } temp = arr[j+1]; arr [j+1]=arr[j]; arr[j] =temp; } } System.out.println("pass:" +(i+1) + "" + Arrays.toString(arr)); int[] arr (5,3,8,9,1,7,0, 2, 6, 4); System.out.println("before bubble sorting:" + Arrays.toString (arr)); bubblesort (arr); System.out.println("after bubble sorting: "+ Arrays.toString(arr)); 1 -
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer