MCPcopy Create free account
hub / github.com/apna-college/Alpha / selectionSort

Method selectionSort

2_Basic Sorting/SelectionSort.java:6–20  ·  view source on GitHub ↗
(int arr[])

Source from the content-addressed store, hash-verified

4
5public class SelectionSort {
6 public static void selectionSort(int arr[]) {
7 for(int turn=0; turn<arr.length; turn++) {
8 int minPos = turn;
9 for(int j=turn+1; j<arr.length; j++) {
10 if(arr[minPos] > arr[j]) {
11 minPos = j;
12 }
13 }
14
15 //swap
16 int temp = arr[turn];
17 arr[turn] = arr[minPos];
18 arr[minPos] = temp;
19 }
20 }
21
22 public static void selectionSortDescending(int arr[]) {
23 for(int turn=0; turn<arr.length; turn++) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected