Created
August 13, 2017 15:50
-
-
Save keremistan/32fee85dbd22afd3c36b8f2f232dbc69 to your computer and use it in GitHub Desktop.
Eklemeli siralamanin nasil uygulanabilecegini gordugumuz ornek bir kod...
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 insertion_sort(dizi: list): | |
for j in range(1, len(dizi)): | |
guncel = dizi[j] | |
i = j - 1 | |
while i >= 0 and dizi[i] > guncel: | |
dizi[i+1] = dizi[i] | |
i = i - 1 | |
dizi[i+1] = guncel | |
return dizi | |
if __name__=="__main__": | |
dizi = [3, 6, 1, 2, 4, 5] | |
dizi = insertion_sort(dizi) | |
for i in dizi: | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment