Skip to content

Commit

Permalink
Fixed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dduirs committed Apr 18, 2024
1 parent 0de86a5 commit 7d60baf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tasks/python/medium/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
def bubble_sort(arr):
# TODO: Implement the bubble sort algorithm
arr_length = len(arr)
for position in arr:
index = 0
while index < arr_length-1:
if arr[index] < arr[index+1]:
arr.insert(index,arr[index])
if arr[index] > arr[index+1]:
arr.insert(index+2,arr[index])
arr.pop(index)
index += 1
return arr

#! Test cases (Don't edit):
arr = [64, 25, 12, 22, 11]
Expand Down

0 comments on commit 7d60baf

Please sign in to comment.