Sunday, 12 January 2020

QUESTION:-BUBBLE SORT




class bs
{
    void main(int a[])
    {
        int l=a.length;
        for(int i=0;i<l-1;i++)
    {
            
            for(int j=0;j<l-1-i;j++)
            {
                if(a[j]>a[j+1])
                 {
                     int t=a[j];
                     a[j]=a[j+1];
                     a[j+1]=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...