Last active
September 16, 2020 06:15
-
-
Save thien/8b94c98c290e7462bd905ba4baeb4e31 to your computer and use it in GitHub Desktop.
A recursive SelectionSort algorithm written in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selection(list, i, j, flag): | |
size = len(list) | |
if (i < size - 1): | |
if (flag): | |
j = i + 1; | |
if (j < size): | |
if (list[i] > list[j]): | |
list[i], list[j] = list[j], list[i] | |
selection(list, i, j + 1, 0); | |
selection(list, i + 1, 0, 1); | |
# print(list) | |
list = [6, 2, 3, 7, 9, 1, 4, 10, 8, 5] | |
selection(list, 0, 0, 1) | |
print(list) |
what does the flag represent in the code?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi thanks for this script. here is a revision: