Fisher-Yates shuffle
Is an algorithm for generating a random permutation of a finite sequence in linear time and constant space.
Is an algorithm for generating a random permutation of a finite sequence in linear time and constant space.
#include "vector.hpp"
#include "fisher_yates.hpp"
#include <iostream>
int main() {
srand(time(0));
dby::vector<int> vec = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
dby::FisherYates::shuffle(vec);
for (int num : vec) {
std::cout << num << ' ';
}
return 0;
}