int main(const int argc, const char* const argv[]) { test_insertion(vec_t{{}}); test_insertion(vec_t{{3,5,1,7,9,2}}); for (int a = -2; a <= 2; ++a) for (int b = -2; b <= 2; ++b) for (int c = -2; c <= 2; ++c) for (int d = -2; d <= 2; ++d) test_insertion(vec_t{{a,b,c,d}}); run_insertion(); }
int main() { auto empty = std::vector<int> {}; auto singleton = std::vector<int> { 1 }; auto doubleton = std::vector<int> { 1, 2 }; auto random = std::vector<int> { 5, 1, 3, 4, 8, 7, 2, 9, 0, 6 }; auto sorted = std::vector<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; auto reversed = std::vector<int> { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; auto nearly_sorted = std::vector<int> { 0, 1, 3, 2, 4, 5, 7, 6, 8, 9 }; auto few_unique = std::vector<int> { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0 }; auto inputs = std::vector<std::vector<int>> { empty, singleton, doubleton, random, sorted, reversed, nearly_sorted, few_unique }; clock_t t; t = clock(); test_selection(begin(inputs), end(inputs)); t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("selection_sort took %f seconds to execute \n\n", time_taken); t = clock(); test_insertion(begin(inputs), end(inputs)); t = clock() - t; time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("insertion_sort took %f seconds to execute \n\n", time_taken); t = clock(); test_quick(begin(inputs), end(inputs)); t = clock() - t; time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("quick_sort took %f seconds to execute \n\n", time_taken); t = clock(); test_merge(begin(inputs), end(inputs)); t = clock() - t; time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("merge_sort took %f seconds to execute \n\n", time_taken); t = clock(); test_heap(begin(inputs), end(inputs)); t = clock() - t; time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("heap_sort took %f seconds to execute \n\n", time_taken); }
int main() { test_insertion(); return boost::report_errors(); }