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
Prev Previous commit
Next Next commit
selection_sort complete
  • Loading branch information
Hunter315 committed Jan 16, 2019
commit 6d8b580ad39f19b2806d287a5dcc443c5f7f395f
8 changes: 6 additions & 2 deletions project/iterative_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ def selection_sort( arr ):
smallest_index = cur_index
# TO-DO: find next smallest element
# (hint, can do in 3 loc)

for j in range(cur_index, len(arr)):
if arr[j] < arr[smallest_index]:
smallest_index = j



# TO-DO: swap

temp = arr[smallest_index]
arr[smallest_index] = arr[cur_index]
arr[cur_index] = temp



Expand Down