Bubble Sort

Bubble Short is a one type of Algorithm. We can use this Algorithm short our value in Increasing Order or Decreassing Order. Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.



Bubble Sort Algorithm Implementation

                    

                    x=[]
                    n=int(input("How many no to want run the programe"))
                    print("Enter a Number")
                    for a in range(n):
                        x.append(int(input()))
                    for j in range (len(x)-1):
                        for i in range (len(x)-1-j):
                           if x[i]>x[i+1]:
                                x[i],x[i+1] = x[i+1],x[i]
                                print(x)
                           else:
                               print(x)
                           print()
                    print(x)
                
                

Booble Short Algorithm Analysis


                    Best Case: O(n)
                    Average Case: O(n^2)
                    Worst Case: O(n^2)
                    Space Complecity: 1
                    Booble Short Algorithm are Internal Shorting Algorithm
                    Booble Short Algorithm are Non-Recursive Shorting Algorithm
                    Stability: Yes Booble Short Algorithm Are Stable Algorithm
                    Adpative: Yes Booble Short Algorithm Are Adpative Algorithm
                   

© Written By Prince Singh