Last active
July 11, 2021 19:37
-
-
Save shameemreza/7cf98d7cd6460b5f0563b2a8309ba5ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1 − Set MIN to location 0 | |
Step 2 − Search the minimum element in the list | |
Step 3 − Swap with value at location MIN | |
Step 4 − Increment MIN to point to next element | |
Step 5 − Repeat until list is sorted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public class LFC {
public static void main(String args[]){
int arr[] = {6, 7, 2, 1, 4};
int size = arr.length;
for (int i = 0 ;i< size-1; i++){
int min = i;
for (int j = i+1; j< size; j++){
if (arr[j] < arr[min]){
min = j;
}
}
int temp = arr[min];
arr[min] = arr[i];
arr[i] = temp;
}
for (int i = 0 ;i< size; i++){
System.out.print(" "+arr[i]);
}
}
}