Sunday, 12 January 2020

QUESTION:-SELECTION SORT


class ss
{
    void main(int a[])
    {
        int l=a.length;
    for(int i=0;i<l-1;i++)
    {
        int min=a[i];
        int p=i;
        for(int j=i+1;j<l;j++)
        {
            if(a[j]<min)
            {
               p=j;
               min=a[j];
            }
        }
           int t=a[i];
            a[i]=a[p];
            a[p]=t;
            
           
    
    }
          for(int i=0;i<l;i++)
    {
    System.out.println(a[i]);
    }
}

}

No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...