[mypy]Correction of all errors in the sorts directory (#4224)

* [mypy] Add/fix type annotations for recursive_insertion_sort(#4085)

* [mypy] Add/fix type annotations for bucket_sort(#4085)

* [mypy] Reworked code for cocktail_shaker_sort so that missing return statement error is resolved(#4085)

* [mypy] Add/fix type annotations for patience_sort(#4085)

* [mypy] Add/fix type annotations for radix_sort(#4085)

Co-authored-by: goodm2 <4qjpngu8mem8cz>
This commit is contained in:
Matthew
2021-02-23 09:02:30 +00:00
committed by GitHub
parent 02d9bc66c1
commit a4726ca248
5 changed files with 12 additions and 7 deletions

View File

@ -27,6 +27,7 @@ If k = O(n), time complexity is O(n)
Source: https://en.wikipedia.org/wiki/Bucket_sort
"""
from typing import List
def bucket_sort(my_list: list) -> list:
@ -51,7 +52,7 @@ def bucket_sort(my_list: list) -> list:
return []
min_value, max_value = min(my_list), max(my_list)
bucket_count = int(max_value - min_value) + 1
buckets = [[] for _ in range(bucket_count)]
buckets: List[list] = [[] for _ in range(bucket_count)]
for i in range(len(my_list)):
buckets[(int(my_list[i] - min_value) // bucket_count)].append(my_list[i])