mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-15 19:30:07 +08:00
formatting source-code for 153fb7b8a5
This commit is contained in:
@@ -4,14 +4,12 @@
|
||||
#include <vector>
|
||||
|
||||
// Function to sort arr[] of size n using bucket sort
|
||||
void bucketSort(float arr[], int n)
|
||||
{
|
||||
void bucketSort(float arr[], int n) {
|
||||
// 1) Create n empty buckets
|
||||
std::vector<float> *b = new std::vector<float>[n];
|
||||
|
||||
// 2) Put array elements in different buckets
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int i = 0; i < n; i++) {
|
||||
int bi = n * arr[i]; // Index in bucket
|
||||
b[bi].push_back(arr[i]);
|
||||
}
|
||||
@@ -27,8 +25,7 @@ void bucketSort(float arr[], int n)
|
||||
}
|
||||
|
||||
/* Driver program to test above funtion */
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
float arr[] = {0.897, 0.565, 0.656, 0.1234, 0.665, 0.3434};
|
||||
int n = sizeof(arr) / sizeof(arr[0]);
|
||||
bucketSort(arr, n);
|
||||
|
||||
Reference in New Issue
Block a user