55 uint32_t size = arr.size();
61 for (
int i = 0; i < size; i += 2) {
62 if (i > 0 && out[i - 1] > out[i]) {
63 std::swap(out[i], out[i - 1]);
66 if (i < size - 1 && out[i] < out[i + 1]) {
67 std::swap(out[i], out[i + 1]);
108 std::srand(std::time(
nullptr));
110 std::vector<float> data1(100);
111 for (
auto &d : data1) {
112 d = float(std::rand() % 1000 - 500) / 100.f;
115 std::vector<float> sorted = sorting::wiggle_sort::wiggleSort<float>(data1);
119 for (uint32_t j = 0; j < data1.size(); j += 2) {
120 assert(data1[j] <= data1[j + 1] &&
121 data1[j + 1] >= data1[j + 2]);
124 std::cout <<
"Test 1 passed\n";