Bubble Sort In Python

This is a simple program which demonstrates the implementation of the bubble sort algorithm in python. The complexity of the program is O(n2) . The Input is taken from the console and then appended to a list, which is further processed .

Output Screen:

Program :

print 'Enter the list of elements followed by space:'
x=raw_input();
x=map(int,x.split())
for i in range(0, len(x)-1):
for j in range(0,len(x)-i-1):
if(x[j]>x[j+1]):
swp=x[j]
x[j]=x[j+1]
x[j+1]=swp
print x

Found suggestions, Please comment them here !

Bikash Panda
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WGLabz
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On

Latest posts by Bikash Panda (see all)

Related posts