mirror of
https://github.com/Bobertkiller/Class-homework.git
synced 2026-01-15 13:02:51 -03:00
new algorithm soon to be more
This commit is contained in:
@@ -32,3 +32,14 @@ def selection(arr):
|
||||
print(selection(a))
|
||||
|
||||
#insertion sort
|
||||
def insertion(arr):
|
||||
for i in range(1,len(arr)):
|
||||
x = arr[i]
|
||||
j = i-1
|
||||
while j>= 0 and x < arr[j]:
|
||||
arr[j + 1] = arr[j]
|
||||
j -= 1
|
||||
arr[j + 1] = x
|
||||
return arr
|
||||
|
||||
print(insertion(a))
|
||||
Reference in New Issue
Block a user