Added selectionsort
This commit is contained in:
parent
96d79c4cae
commit
52ad9376fe
15
algorithmen/selectionsort.py
Normal file
15
algorithmen/selectionsort.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
l = [12,124,1,31,51,4563,76,43,532,7,98,786,63,68,2,15,764,345,2,7,85]
|
||||||
|
|
||||||
|
def selectionsort(alist):
|
||||||
|
blist = alist[:] # work on a copy
|
||||||
|
result = list()
|
||||||
|
for i in range(len(blist)):
|
||||||
|
# find min element
|
||||||
|
min_e = min(blist)
|
||||||
|
result.append(min_e)
|
||||||
|
blist.remove(min_e)
|
||||||
|
print(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
sorted = selectionsort(l)
|
||||||
|
print(sorted)
|
Loading…
Reference in New Issue
Block a user