We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d8e015 commit 717f5c8Copy full SHA for 717f5c8
sorting/bucket_sort.cpp
@@ -6,7 +6,7 @@
6
// Function to sort arr[] of size n using bucket sort
7
void bucketSort(float arr[], int n) {
8
// 1) Create n empty buckets
9
- std::vector<float> b[n];
+ std::vector<float> *b = new std::vector<float>[n];
10
11
// 2) Put array elements in different buckets
12
for (int i = 0; i < n; i++) {
@@ -21,6 +21,7 @@ void bucketSort(float arr[], int n) {
21
int index = 0;
22
for (int i = 0; i < n; i++)
23
for (int j = 0; j < b[i].size(); j++) arr[index++] = b[i][j];
24
+ delete[] b;
25
}
26
27
/* Driver program to test above funtion */
0 commit comments