MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / selectionSort

Method selectionSort

Programs/SelectionSort.java:9–23  ·  view source on GitHub ↗
(int[] arr)

Source from the content-addressed store, hash-verified

7public class SelectionSortMain {
8
9 public static int[] selectionSort(int[] arr){
10
11 for (int i = 0; i < arr.length - 1; i++)
12 {
13 int index = i;
14 for (int j = i + 1; j < arr.length; j++)
15 if (arr[j] < arr[index])
16 index = j;
17
18 int smallerNumber = arr[index];
19 arr[index] = arr[i];
20 arr[i] = smallerNumber;
21 }
22 return arr;
23}
24
25 public static void main(String a[]){
26 int[] arr = {40,10,-30,45,39,32};

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected