Java Sorting-java sorting algorithms selection sort code - Java Sorting-java sorting algorithms selection sort code

selection sort code

The implementation of the selection sort algorithm in our Array class could look like this:
public void selectSort()
{
int i,j,min;
for (i=0;i
{
min=i; //The first element is the first minimum

for (j = i+1;j

if(data[j] < data[min])//if new item smaller

min = j;//It is the new minimum

swap(i,min);
}
}


or you can see example from this video from youtube
watch me

1 comments:

Post a Comment