Uygulama Konusu: Tanımlanmış olan diziyi selection sort mantığıyla sıralar ve kaydeder.
def selectionSort(alist):
for slot in range(len(alist)-1,0,-1):
max=0
for location in range(1,slot+1):
if alist[location]>alist[max]:
max = location
temp = alist[slot]
alist[slot] = alist[max]
alist[max] = temp
mylist = [54,26,93,17,77,31,44,55,20]
selectionSort(mylist)
print(mylist)
Hiç yorum yok:
Yorum Gönder