@anonymous/

SnowEveryModel

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def counting_sort(input_list, max_int):
  
  count = [0] * (max_int + 1)
  for i in range(len(input_list)):
    value = input_list[i]
    count[value] += 1
  print("Count", count)
  
  modified_count = [i for i in count]
  for i in range(1, len(count)):
    modified_count[i] = modified_count[i-1] + modified_count[i]
  print("Modified count", modified_count)
  
  output = [0] * len(input_list)
  for i in range(len(input_list)):
    output_value = input_list[i]
    output_index = modified_count[output_value] - 1
    output[output_index] = output_value
    modified_count[input_list[i]] -= 1
  print("Output", output)


counting_sort([1,0,5,7,6,2,1,2], 7)