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
fixed iterate_sorting
  • Loading branch information
fellanonymous committed Jan 17, 2019
commit 806bd7fd36a180eaada461d6d427c5c0c91db638
13 changes: 7 additions & 6 deletions project/iterative_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ 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
cur_index = i
print(arr)
while cur_index > 0 and arr[cur_index] < arr[cur_index - 1]:
temp = arr[cur_index - 1]
arr[cur_index - 1] = arr[cur_index]
arr[cur_index] = 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. 😄



Expand Down