Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Go ahead and add a one line intro about you and add your favorite emoji (you can

- Hi, my name is Brandon and my favorite emoji is 🍔

- Hi, my name is Hasan and my favorite emoji is 😅

## Conclusion
Thank you for the overwhelming amount of contributions! I hope that everybody made their 4 pull requests for Hacktoberfest, and that your journey to open source doesn't end here. I am *slowly* getting through the pull requests. Check back if you don't see your changes in this repo! Best of luck :)

Expand Down
Binary file removed sorting/bubble.pyc
Binary file not shown.
Binary file removed sorting/heap.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions sorting/selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def selection(numbers):

# Traverse through the array
for i in range(len(numbers)):

# Find the index of the minimum element in remaining sorted array
min_index = i
for j in range(i+1, len(numbers)):
if numbers[min_index] > numbers[j]:
min_index = j

# Swap the found minimum element with this index
numbers[i], numbers[min_index] = numbers[min_index], numbers[i]

#return the sorted array
return numbers
9 changes: 9 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@
print "Bucket Sort incorrect"
except:
print "Bucketsort function errored or is incomplete"

try:
from selection import selection
if(selection(list(nums)) == sortedNums):
print "selectionsort success!"
else:
print "selectionsort incorrect."
except:
print "selectionsort function errored or is incomplete."