mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
[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:
@ -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])
|
||||
|
Reference in New Issue
Block a user