48std::vector<uint64_t> selectionSort(
const std::vector<uint64_t> &arr,
50 std::vector<uint64_t> array(
53 for (uint64_t it = 0; it < len; ++it) {
55 for (uint64_t it2 = it + 1; it2 < len; ++it2) {
56 if (array[it2] < array[min]) {
62 uint64_t tmp = array[min];
63 array[min] = array[it];
79 std::vector<uint64_t> vector1 = {1, 0, 0, 1, 1, 0, 2, 1};
80 uint64_t vector1size = vector1.size();
81 std::cout <<
"1st test... ";
82 std::vector<uint64_t> result_test1;
83 result_test1 = sorting::selectionSort(vector1, vector1size);
84 assert(std::is_sorted(result_test1.begin(), result_test1.end()));
85 std::cout <<
"Passed" << std::endl;
90 std::vector<uint64_t> vector2 = {19, 22, 540, 241, 156, 140, 12, 1};
91 uint64_t vector2size = vector2.size();
92 std::cout <<
"2nd test... ";
93 std::vector<uint64_t> result_test2;
94 result_test2 = sorting::selectionSort(vector2, vector2size);
95 assert(std::is_sorted(result_test2.begin(), result_test2.end()));
96 std::cout <<
"Passed" << std::endl;
100 std::vector<uint64_t> vector3 = {11, 20, 30, 41, 15, 60, 82, 15};
101 uint64_t vector3size = vector3.size();
102 std::cout <<
"3rd test... ";
103 std::vector<uint64_t> result_test3;
104 result_test3 = sorting::selectionSort(vector3, vector3size);
105 assert(std::is_sorted(result_test3.begin(), result_test3.end()));
106 std::cout <<
"Passed" << std::endl;
111 std::vector<uint64_t> vector4 = {1, 9, 11, 546, 26, 65, 212, 14};
112 uint64_t vector4size = vector2.size();
113 std::cout <<
"4th test... ";
114 std::vector<uint64_t> result_test4;
115 result_test4 = sorting::selectionSort(vector4, vector4size);
116 assert(std::is_sorted(result_test4.begin(), result_test4.end()));
117 std::cout <<
"Passed" << std::endl;