Created
March 18, 2019 15:46
-
-
Save simondegheselle/a0fe6a63cb06bafa6e047ca2a9a9c876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by simon on 17/03/19. | |
// | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
#include "insertion_sort.h" | |
#include <cmath> | |
using namespace std; | |
// segmentation fault, maar normaal is dit wel juist | |
void bucket_sort(vector<double> &v, int n) { | |
vector<vector<double>> b(n); | |
for (int i = 0; i < v.size(); i++) { | |
double firstDigit = v[i] * 10; | |
int bi = int(std::floor(firstDigit)); | |
b[0].push_back(v[i]); | |
} | |
for(int i = 0; i < b.size(); i++) { | |
insertion_sort(b[i]); | |
} | |
int in =0; | |
for(int i = 0; i < b.size(); i++){ | |
for(int j = 0; j < b[i].size(); j++) { | |
v[in++] = b[i][j]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment