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

Function bucketSort

CPP/sorting/bucketsort.cpp:4–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4void bucketSort(float arr[], int n)
5{
6 vector<float> b[n];
7 for (int i = 0; i < n; i++) {
8 int bi = n * arr[i];
9 b[bi].push_back(arr[i]);
10 }
11 for (int i = 0; i < n; i++)
12 sort(b[i].begin(), b[i].end());
13 int index = 0;
14 for (int i = 0; i < n; i++)
15 for (int j = 0; j < b[i].size(); j++)
16 arr[index++] = b[i][j];
17}
18
19int main()
20{

Callers 1

mainFunction · 0.70

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected