Hello Guys, I welcome you in  my blog. Today we will learn more about Bubble Sort .

  In Bubble Sort we learn about :-

  1. Short Concepts About complexity of  Bubble Sort.
  2. Bubble Sort Code.
  3. Bubble Sort Algorithm.
  4. Bubble Sort Proof of correctness.

  • Short Concepts About complexity of  Bubble Sort.




  • 2) Bubble Sort Code.


    #include<bits/stdc++.h>
    using namespace std;
    //int swap(int a[j],a[]);
    void Bubblesort(int a[],int n)
    {
       for(int i=0;i<n-1;i++)
       {
        for(int j=0;j<n-i-1;j++)
        {
              if(a[j]>a[j+1])
              {
                swap(a[j],a[j+1]);
              }
        }

       }
    }
    int printbubble(int a[],int n)
    {
       for(int i=0;i<n;i++)
       {
        cout<<a[i]<<" ";
        cout<<endl;
       }
    }

    int main()
    {
       
        int n;
        cout<<"Enter The Array Limit :";
        cin>>n;
        cout<<"Enter The Elements Of Array";
        int a[n];
        for(int i=0;i<n;i++)
        {
           cin>> a[i];
        }
      //  n=sizeof(a)/sizeof(int);
        Bubblesort(a,n);
        cout<<"Sorted array :-"<<endl;
        printbubble(a,n);
        return 0;
    }



    3) Bubble Sort Algorithm.


    4) Example /proof of correctness.