Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

January 2, 2010

Selection Sort

public static int[] selectionSort(int[] arr){
int len = arr.length;

for (int i = 0 ; i < len ; i++){
int min = arr[i];
for(int j = i + 1 ; j < len ; j++){
if(min > arr[j]){
int temp = arr[j];
arr[j] = min;
min = temp;
arr[i] = min;
}
}

}
return arr;
}

No comments: