Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions bubbleSort.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
print("Enter the array to be sorted \n")
a = [int(i) for i in input().split()]

for i in range(len(a)-1):
for j in range(len(a)-1):
if a[j] > a[j+1]:
# swap= ar[j];
# ar[j] =ar[j+1];
# ar[j+1]= swap;
a[j], a[j+1] = a[j+1] , a[j];
swapped = True
for i in range(len(a)-1, 0, -1):
if not swapped:
break
swapped = False
for j in range(i):
if a[j] > a[j+1]:
a[j], a[j+1] = a[j+1] , a[j]
swapped = True


print("Acending Order Sorted Array" ,a)
print("Acending Order Sorted Array" ,a)