023f5e092d38f7e220ae68a23f7183eeb8fd9e04,sorts/bucket_sort.py,,bucket_sort,#Any#Any#,17

Before Change



    sorted_array=[]
    for i in range(len(buckets)):
        buckets[i].sort()
        for j in range(len(buckets[i])):
            sorted_array.append(buckets[i][j])
    return sorted_array

After Change


DEFAULT_BUCKET_SIZE=5

def bucket_sort(my_list, bucket_size=DEFAULT_BUCKET_SIZE):
    if len(my_list) == 0:
        raise Exception("Please add some elements in the array.")

    min_value, max_value = (min(my_list), max(my_list))
    bucket_count = ((max_value - min_value) // bucket_size + 1)
    buckets = [[] for _ in range(int(bucket_count))]

    for i in range(len(my_list)):
        buckets[int((my_list[i] - min_value) // bucket_size)].append(my_list[i])
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: TheAlgorithms/Python
Commit Name: 023f5e092d38f7e220ae68a23f7183eeb8fd9e04
Time: 2019-05-22
Author: vargasnikolass@gmail.com
File Name: sorts/bucket_sort.py
Class Name:
Method Name: bucket_sort


Project Name: J535D165/recordlinkage
Commit Name: f0abbde5a393b8781919a2c33474757c07cfee8f
Time: 2016-01-02
Author: jonathandebruinhome@gmail.com
File Name: recordlinkage/indexing.py
Class Name:
Method Name: _sortedneighbourhood


Project Name: lmcinnes/umap
Commit Name: 52424aae5e284440efdb4aea30266a69553d1dde
Time: 2018-09-29
Author: joseph.m.courtney@gmail.com
File Name: umap/umap_.py
Class Name: UMAP
Method Name: transform