Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW selectionsort using while
#python 3.5.2 #print ("Hello, world!") def SelectionSort(y): length=len(y) nlastposition=length-1 numindex=0 while nlastposition >=0: numbindex =0 while numbindex < nlastposition+1: maxindex=0 if y[numindex] > y[maxindex]: maxindex = numindex 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
calcultion
sai hw
wordchangething
Assignment-2a
15
PySlots
prime number
Filter String
inverse matrix gauss jordan
ganesh