diff --git a/sorting/wave_sort.cpp b/sorting/wave_sort.cpp index 20b496ecc..8b19394cf 100644 --- a/sorting/wave_sort.cpp +++ b/sorting/wave_sort.cpp @@ -2,12 +2,13 @@ * @file * @brief Implementation of [Wave sort] algorithm * @details - * Wave Sort is a sorting algorithm that works in \f$O(nlogn)\f$ time assuming the sort function used works in \f$O(nlogn)\f$ time. + * Wave Sort is a sorting algorithm that works in \f$O(nlogn)\f$ time assuming + * the sort function used works in \f$O(nlogn)\f$ time. * @author [Swastika Gupta](https://github.com/swastyy) */ -#include /// for assert #include /// for std::is_sorted, std::swap +#include /// for assert #include /// for io operations #include /// for std::vector @@ -31,12 +32,12 @@ template std::vector waveSort(const std::vector &in_arr, int n) { std::vector arr(in_arr); - for (int i=0;i array1 = {10, 90, 49, 2, 1, 5, 23}; std::cout << "Test 1... "; - std::vector arr1 = sorting::wave_sort::waveSort(array1,7); + std::vector arr1 = sorting::wave_sort::waveSort(array1, 7); const std::vector o1 = {2, 1, 10, 5, 49, 23, 90}; - assert(arr1==o1); + assert(arr1 == o1); std::cout << "passed" << std::endl; // [1, 3, 4, 2, 7, 8] return [2, 1, 4, 3, 8, 7] std::vector array2 = {1, 3, 4, 2, 7, 8}; std::cout << "Test 2... "; - std::vector arr2 = sorting::wave_sort::waveSort(array2,6); + std::vector arr2 = sorting::wave_sort::waveSort(array2, 6); const std::vector o2 = {2, 1, 4, 3, 8, 7}; - assert(arr2==o2); + assert(arr2 == o2); std::cout << "passed" << std::endl; // [3, 3, 3, 3] return [3, 3, 3, 3] std::vector array3 = {3, 3, 3, 3}; std::cout << "Test 3... "; - std::vector arr3 = sorting::wave_sort::waveSort(array3,4); + std::vector arr3 = sorting::wave_sort::waveSort(array3, 4); const std::vector o3 = {3, 3, 3, 3}; - assert(arr3==o3); + assert(arr3 == o3); std::cout << "passed" << std::endl; // [9, 4, 6, 8, 14, 3] return [4, 3, 8, 6, 14, 9] std::vector array4 = {9, 4, 6, 8, 14, 3}; std::cout << "Test 4... "; - std::vector arr4 = sorting::wave_sort::waveSort(array4,6); + std::vector arr4 = sorting::wave_sort::waveSort(array4, 6); const std::vector o4 = {4, 3, 8, 6, 14, 9}; - assert(arr4==o4); + assert(arr4 == o4); std::cout << "passed" << std::endl; }