Bubble Sort in list Program in Python

Python
Python


Code:

a=[6,4,8,3,9,76,45,32,90,108]
n=len(a)
for i in range(n-1,-1,-1):
    for j in range(i):
        if(a[j] > a[j+1]):
            a[j],a[j+1]=a[j+1],a[j]
print(a)

Output:

[3, 4, 6, 8, 9, 32, 45, 76, 90, 108]
>>>

Tags: 
bubble sort,bubble sort in python,python,bubble sort algorithm in python,bubble sort python,bubble sort algorithm,python bubble sort,sort,bubble sort program in python,bubble sort algorithm python,bubble sort in python using list,algorithms in python,python programming,bubble sort in python 3,#bubble sort in python,bubble sort in python hindi,bubble sort program python

Post a Comment

Previous Post Next Post