Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW Descending order Insertion Sort
#python 3.5.2 print ("Hello, world!") def selectionSort(alist): length = len(alist) for nLastPosition in range(length-1, 0, -1): # nLastPosition -> 5 -> 4 -> 3 -> 2 -> 1 # this loop goes from last position to first position # 1: identifying the maximum number [come back to this] minIndex = 0 for numIndex in range(0, nLastPosition+1): if alist[numIndex] < alist[minIndex]: minIndex = numIndex print ("Min number: ", alist[minIndex]) temp = alist[nLastPosition] alist[nLastPosition] = alist[minIndex] alist[minIndex] = temp print ("After swap: ", alist) print () return alist alist = [26,54,93,17,77,31] # length = 6 sortList = selectionSort(alist) print (sortList)
run
|
edit
|
history
|
help
0
Merge sort implementation
Regular falsi
tree
.....✓[Guess the number]®®®®®®®•$$$$✓.....
default argument
print path module python
Assignment-3a
7 Segment Display
Random SUm
Привет