Skip to content
Open
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
Next Next commit
insertion_sort in iterative sorting complete
  • Loading branch information
Hunter315 committed Jan 16, 2019
commit 8e4d8327f9705558f761f7edc425c2a79c22bc60
8 changes: 7 additions & 1 deletion project/iterative_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def selection_sort( arr ):

# TO-DO: implement the Insertion Sort function below
def insertion_sort( arr ):

for i in range(1, len(arr)):
key = i
j = i - 1
while j >= 0 and key < arr[j]:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key
return arr


Expand Down