Skip to content

Commit 8924e9f

Browse files
committed
Made balancing changes to statistics part 1
1 parent f25dfac commit 8924e9f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

algorithms/Comparison.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
temp = array[:]
2424
bubble_sort(temp)
2525
temp = array[:]
26-
bucket_sort(temp)
26+
bucket_sort(temp, how_many // 100)
2727
temp = array[:]
2828
comb_sort(temp)
2929
temp = array[:]

algorithms/bucketSort.py

+3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,20 @@ def bucket_sort(arr, k=5):
2626
for i in range(k):
2727
buckets.append([])
2828
newTab = []
29+
array_accesses += len(arr)
2930
maximum = max(arr)
3031
for i in range(len(arr)):
3132
array_accesses += 1
3233
index = int(k * arr[i] / maximum)
3334
if index == k:
3435
index -= 1
36+
array_accesses += 3
3537
buckets[index].append(arr[i])
3638
for i in range(k):
3739
(comparisons, array_accesses) = insertion_sort(
3840
buckets[i], comparisons, array_accesses)
3941
for j in range(len(buckets[i])):
42+
array_accesses += 2
4043
newTab.append(buckets[i][j])
4144
print("Bucket sort:")
4245
print("No. comparisons: " + str(comparisons) +

0 commit comments

Comments
 (0)