Bubble sort Algorithm.





Bubble sort is a simple sorting algorithm.this is not suitable for large data sets,Bubble sort is start with two very first element, comparing and check which one is greater than, In this image 5 is less than to 6, these two values must be swapped, So doing this process continuously,When the process is not complete, it is doing the same things.


code:

def BubbleSort(arr):
    n=len(arr);
    for i in range(0,n):
        for j in range(0,n-i-1):
            
            if arr[j]>arr[j+1]:
                arr[j],arr[j+1]=arr[j+1],arr[j];

arr=[9,8,7,6,5,4,3,2,1,0];
obj=BubbleSort(arr);
for i in range(len(arr)):
    print(arr);
    if i==0:
        break;