Space -Komplexitätsrechner online
def countingSort(array, place):
size = len(array)
output = [0] * size
count = [0] * 10
# Calculate count of elements
for i in range(0, size):
index = array[i] // place
count[int(index) % 10] += 1
# Calculate cumulative count
for i in range(1, 10):
count[i] += count[i - 1]
# Place the elements in sorted order
i = size - 1
while i >= 0:
index = array[i] // place
output[count[int(index) % 10] - 1] = array[i]
count[int(index) % 10] -= 1
i -= 1
for i in range(0, size):
array[i] = output[i]
for j in range(1, size):
if liste[j-1] > liste[j] and int(liste[j-1]) == int(liste[j]):
temp = array[j-1]
array[j-1] = array[j]
array[j] = temp
Umut Bilgen