forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelection_Sort.java
More file actions
Latest commit
22 lines (21 loc) · 606 Bytes
/
Copy pathSelection_Sort.java
File metadata and controls
22 lines (21 loc) · 606 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importjava.util.*;
publicclassSelection_Sort {
publicstaticvoidmain(String[] args) {
int[]arr={1,22,3,42,5,2,94};
int []arrs={8,0,7,1,3};
selectionsort(arrs);
System.out.println(Arrays.toString(arrs));
}
staticvoidselectionsort(int[]arr){
for (inti = 0; i < arr.length-1; i++) {
intmin=i;
for (intj = i+1; j < arr.length ; j++) {
if(arr[j]<arr[min]){
min=j;
}
}inttemp=arr[min];
arr[min]= arr[i];
arr[i] =temp;
}
}
}