You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bucket Sort or Bin Sort](https://en.wikipedia.org/wiki/Bucket_sort) is a distributed sorting algorithm, which sort elements from an array by performing these steps:
3
+
Bucket Sort, also known as Bin Sort, is a distributed sorting algorithm, which sort elements from an array by performing these steps:
4
4
5
5
1) Distribute the elements into buckets or bins.
6
6
2) Sort each bucket individually.
7
-
3) Merge the buckets in order to produce a sort array as results.
8
-
7
+
3) Merge the buckets in order to produce a sorted array as the result.
9
8
10
9
See the algorithm in action [here](https://www.cs.usfca.edu/~galles/visualization/BucketSort.html) and [here](http://www.algostructure.com/sorting/bucketsort.php).
11
10
12
-
13
11
The performance for execution time is:
14
12
15
13
| Case | Performance |
@@ -18,11 +16,11 @@ The performance for execution time is:
18
16
| Best | Omega(n + k) |
19
17
| Average | Theta(n + k) |
20
18
21
-
Where **n** = #elements and **k**= #buckets
19
+
Where **n** = the number of elements and **k**is the number of buckets.
22
20
23
-
On the **best case** the algorithm distributes the elements uniformily between buckets, a few elements are placed on each bucket and sorting the buckets is *O(1)*. Rearranging the elements is one more run through the initial list.
24
-
On the **worst case** the elements are sent all to the same bucket, making the process takes *O(n^2)*.
21
+
In the *best case*, the algorithm distributes the elements uniformily between buckets, a few elements are placed on each bucket and sorting the buckets is **O(1)**. Rearranging the elements is one more run through the initial list.
25
22
23
+
In the *worst case*, the elements are sent all to the same bucket, making the process take **O(n^2)**.
26
24
27
25
## Pseudocode
28
26
@@ -39,22 +37,22 @@ A [pseudocode](https://en.wikipedia.org/wiki/Bucket_sort#Pseudocode) of the algo

49
47
50
-
##An example
48
+
##An example
51
49
52
50
### Input
53
51
54
-
Suppose we have the following list of elements: `[2, 56, 4, 77, 26, 98, 55]`.
55
-
And we define 10 buckets will be used. To determine the capacity of each bucket we need to know the `maximum element value`, in this case `98`.
52
+
Suppose we have the following list of elements: `[2, 56, 4, 77, 26, 98, 55]`. Let's use 10 buckets. To determine the capacity of each bucket we need to know the *maximum element value*, in this case `98`.
0 commit comments