Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
first try
  • Loading branch information
fellanonymous committed Jan 17, 2019
commit 30b9c93658464abbd7d53ea683dea94ad322e308
11 changes: 11 additions & 0 deletions project/iterative_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ def selection_sort(arr):


def insertion_sort(arr):
for i in range(1, len(arr)):
# cur_index = i
while arr[i] < arr[i - 1]:
temp = arr[i - 1]
arr[i - 1] = arr[i]
arr[i] = temp
# cur_index -= 1
return arr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to say you got this one working, too. Maybe today you can work on quicksort in the recursive file. 😄



print(insertion_sort([22, 55, 77, 44, 66, 88, 11, 33]))

# STRETCH: implement the Bubble Sort function below


def bubble_sort(arr):

return arr
Expand Down