Monday, 21 August 2017

BUBBLE SORT

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

No comments:

Post a Comment