Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e26bd34

Browse files
author
Amogh Singhal
authored
Merge pull request devAmoghS#18 from mangeshacs/patch-1
Update bubble_sort.py
2 parents ee2c572 + 075fa49 commit e26bd34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎bubble_sort.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def bubbleSortOptimized(arr):
2424

2525
for j in range(0, len(arr)-i-1):
2626

27-
if arr[i] > arr[j]:
28-
arr[i], arr[j] = arr[j], arr[i]
27+
if arr[j] > arr[j+1]:
28+
arr[j], arr[j+1] = arr[j+1], arr[j]
2929
swapped = True
3030

3131
# if no elements are swapped, break the loop

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /