Python Program for Bubble Sort
Bubble sort is one of the simplest sorting technique to
sort the data items.
#Python Bubble Sort Program
arr=[50,40,10,30,60]
length=len(arr)
for i in range(length):
for j in range(0,length-i-1):
if arr[j]>arr[j+1]:
temp=arr[j]
arr[j]=arr[j+1]
arr[j+1]=temp
print("the sorted list is:")
for i in range(length):
print(arr[i])
Output:
Written
By:
Trilochan
Tarai
SILAN
Technology,BBSR
Comments
Post a Comment