Monday, 21 August 2017

SELECTION SORT

void SelectionSort(int a[],int n)
{              int i,small,pos,temp;
            for(i=0;i<n;i++)
            {           small=a[i];
                         pos=i;
                        for(j=i+1;j<n;j++)
                        {  if(a[j]<small)
                                    {small=a[j];
                                    pos=j;}
                        }
            temp=a[i];
            a[i]=a[pos];
            a[pos]=temp;
            cout<,”\n After Pass “<<i+1 ;
            for(j=0;j<n;j++)
                        cout<<a[j];
} }

No comments:

Post a Comment