Selection Sort

  these picture shows that the algorithm of the selection sort the code is below in (java)
public class selectionSort{
public void sort(int[] A){
for(int i=0; i<A.length; i++){
int minIndex =i;
for(int j=i; j<A.length; j++){
if(A[minIndex] > A[j]){
minIndex = j;
   // Swapping the minIndex Element and first element 
int temp = A[i];
A[i] = A[minIndex];
A[minIndex] = temp;

public class selectionSortDemo{
public static void main(String args[]){
int A[] = {7,3,2,5,1};
selectionSort S = new selectionSort();
for(int i=0; i<A.length; i++){
System.out.print(A[i]+” “);



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s