MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / bucketSort

Function bucketSort

Python/all sorting methods.py:46–65  ·  view source on GitHub ↗
(customList)

Source from the content-addressed store, hash-verified

44from xmlrpc.server import MultiPathXMLRPCServer
45
46def bucketSort(customList):
47 numberofBuckets = round(math.sqrt(len(customList)))
48 maxValue = max(customList)
49 arr =[]
50
51 for i in range(numberofBuckets):
52 arr.append([])
53 for j in customList:
54 index_b = math.ceil(j*numberofBuckets/maxValue)
55 arr[index_b-1].append(j)
56
57 for i in range(numberofBuckets):
58 arr[i] = insertionSort(arr[i])
59
60 k = 0
61 for i in range(numberofBuckets):
62 for j in range(len(arr[i])):
63 customList[k] = arr[i][j]
64 k+=1
65 return customList
66
67
68

Callers

nothing calls this directly

Calls 4

ceilMethod · 0.80
insertionSortFunction · 0.70
maxFunction · 0.50
sqrtMethod · 0.45

Tested by

no test coverage detected