Last active
June 5, 2020 18:45
-
-
Save harveychurch/558a43e8e7054598dec1ad751cae8ac6 to your computer and use it in GitHub Desktop.
Sorting Algorigthm: "Something Sort". This is not efficient.
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 somethingSort(array): | |
pointer = 0 | |
number_of_comparisons = 0 | |
while pointer < len(array)-1: | |
if array[pointer] > array[pointer+1]: | |
array[pointer+1],array[pointer] = array[pointer],array[pointer+1] | |
pointer = 0 | |
else: | |
pointer += 1 | |
number_of_comparisons += 1 | |
return array,number_of_comparisons |
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
This was an experiment whilst reteaching myself sorting algorithms in preperation for interviews. | |
It is no means efficient or smart, but a mistake that led to an interesting observation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment