Exchange Sort¶
Take your exchange sort inner loop code and insert it in the following file in the appropriate loactions:
What to do¶
Take the inner loop from the previous assignment and place it in the
exchange_sort
function.There is a
swap
function already written for you. You must call thatswap
function from yourexchange_sort
function when it is required.Nest your exchange sort inner loop inside of another loop that will be responsible for incrementing the
marker
variable from0
the length of the list to be sorted.
before: 45 87 39 32 93 86 12 44 75 50
after : 12 32 39 44 45 50 75 86 87 93
Note, the starter code generates random numbers so your output will have different numbers, but should still be sorted by the end.
©2021 Daniel Gallo
This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Adapted for Python from Graham Mitchell’s Programming By Doing