public static void selectionSort(int[] arr) 1 int length-arr.length; int i=0.j-0,temp=0, minIndex=0; for(i=0;i

icon
Related questions
Question

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

public static void selectionSort(int[] arr)
X
int length = arr.length;
int i=0.j-0,temp=0, minIndex=0;
for(i=0;i<length-1;i++)// outer loop
1
minIndex-i;
for(j=i+1;j<=length-1;j++)// inner loop
if(arr[j]<arr[minIndex])
minIndex-j;
{
}
temp = arr[i];
arr[i]=arr[minIndex];
arr[minIndex] temp;
}
} // end selectionSort()
Transcribed Image Text:public static void selectionSort(int[] arr) X int length = arr.length; int i=0.j-0,temp=0, minIndex=0; for(i=0;i<length-1;i++)// outer loop 1 minIndex-i; for(j=i+1;j<=length-1;j++)// inner loop if(arr[j]<arr[minIndex]) minIndex-j; { } temp = arr[i]; arr[i]=arr[minIndex]; arr[minIndex] temp; } } // end selectionSort()
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer