Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW5, SelectionSort FINNAL
#python 3.5.2 #print ("Hello, world!") def SelectionSort(y): length=len(y) nlastposition=length-1 while nlastposition >=0: numbindex =0 maxindex=0 while numbindex < nlastposition+1: if y[numbindex] > y[maxindex]: maxindex = numbindex numbindex=numbindex+1 print ("Max number: ", y[maxindex]) temp = y[nlastposition] y[nlastposition] = y[maxindex] y[maxindex] = temp print ("After swap: ", y) print () nlastposition=nlastposition-1 return y s = [26,54,93,17,77,31] sortList = SelectionSort(s) print (sortList)
run
|
edit
|
history
|
help
0
Tupples
3564
cls_var und cls_method
I_Love_India
Venture
hw11
teste
shivareddy correct
BasicFunctionsPrograms,py
SceneGraph Interviewee Task