diff --git a/data_structures/morrisinorder.cpp b/data_structures/morrisinorder.cpp index c667ccf13fa..edc1daa6d6f 100644 --- a/data_structures/morrisinorder.cpp +++ b/data_structures/morrisinorder.cpp @@ -1,9 +1,9 @@ #include #include -/************************** +/** @author shrutisheoran -**************************/ + */ using namespace std; diff --git a/dynamic_programming/partition_problem.cpp b/dynamic_programming/partition_problem.cpp index 0dbfaa1d740..b3e194b66bc 100644 --- a/dynamic_programming/partition_problem.cpp +++ b/dynamic_programming/partition_problem.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/** * @file * @brief Implementation of the [Partition * Problem](https://en.wikipedia.org/wiki/Partition_problem ) @@ -26,31 +26,31 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * - *******************************************************************************/ + */ #include /// for assert #include /// for std::uint64_t #include /// for IO Operations #include /// for std::accumulate #include /// for std::vector -/****************************************************************************** +/** * @namespace dp * @brief Dynamic programming algorithms - *******************************************************************************/ + */ namespace dp { -/****************************************************************************** +/** * @namespace partitionProblem * @brief Partition problem algorithm - *******************************************************************************/ + */ namespace partitionProblem { -/****************************************************************************** +/** * @brief Returns true if arr can be partitioned in two subsets of equal sum, * otherwise false * @param arr vector containing elements * @param size Size of the vector. * @returns @param bool whether the vector can be partitioned or not. - *******************************************************************************/ + */ bool findPartiion(const std::vector &arr, uint64_t size) { uint64_t sum = std::accumulate(arr.begin(), arr.end(), 0); // Calculate sum of all elements @@ -82,10 +82,10 @@ bool findPartiion(const std::vector &arr, uint64_t size) { } // namespace partitionProblem } // namespace dp -/******************************************************************************* +/** * @brief Self-test implementations * @returns void - *******************************************************************************/ + */ static void test() { std::vector arr = {{1, 3, 3, 2, 3, 2}}; uint64_t n = arr.size(); @@ -96,10 +96,10 @@ static void test() { std::cout << "Passed!" << std::endl; } -/******************************************************************************* +/** * @brief Main function * @returns 0 on exit - *******************************************************************************/ + */ int main() { test(); // run self-test implementations return 0; diff --git a/geometry/graham_scan_algorithm.cpp b/geometry/graham_scan_algorithm.cpp index ac1435cefec..ff45e883625 100644 --- a/geometry/graham_scan_algorithm.cpp +++ b/geometry/graham_scan_algorithm.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/** * @file * @brief Implementation of the [Convex * Hull](https://en.wikipedia.org/wiki/Convex_hull) implementation using [Graham @@ -37,17 +37,17 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * - *******************************************************************************/ + */ #include /// for std::assert #include /// for IO Operations #include /// for std::vector #include "./graham_scan_functions.hpp" /// for all the functions used -/******************************************************************************* +/** * @brief Self-test implementations * @returns void - *******************************************************************************/ + */ static void test() { std::vector points = { {0, 3}, {1, 1}, {2, 2}, {4, 4}, {0, 0}, {1, 2}, {3, 1}, {3, 3}}; @@ -66,10 +66,10 @@ static void test() { std::cout << "passed!" << std::endl; } -/******************************************************************************* +/** * @brief Main function * @returns 0 on exit - *******************************************************************************/ + */ int main() { test(); // run self-test implementations return 0; diff --git a/geometry/graham_scan_functions.hpp b/geometry/graham_scan_functions.hpp index e5dcbbf2d15..e7530efe6e7 100644 --- a/geometry/graham_scan_functions.hpp +++ b/geometry/graham_scan_functions.hpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/** * @file * @brief Implementation of the [Convex * Hull](https://en.wikipedia.org/wiki/Convex_hull) implementation using [Graham @@ -37,7 +37,7 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * - *******************************************************************************/ + */ #include /// for std::swap #include #include /// for mathematics and datatype conversion @@ -45,22 +45,22 @@ #include /// for std::stack #include /// for std::vector -/****************************************************************************** +/** * @namespace geometry * @brief geometric algorithms - *******************************************************************************/ + */ namespace geometry { -/****************************************************************************** +/** * @namespace graham scan * @brief convex hull algorithm - *******************************************************************************/ + */ namespace grahamscan { -/****************************************************************************** +/** * @struct Point * @brief for X and Y co-ordinates of the co-ordinate. - *******************************************************************************/ + */ struct Point { int x, y; }; @@ -70,11 +70,11 @@ struct Point { Point p0; -/****************************************************************************** +/** * @brief A utility function to find next to top in a stack. * @param S Stack to be used for the process. * @returns Co-ordinates of the Point below the top of the stack - *******************************************************************************/ + */ Point nextToTop(std::stack *S) { Point p = S->top(); S->pop(); @@ -83,24 +83,24 @@ Point nextToTop(std::stack *S) { return res; } -/****************************************************************************** +/** * @brief A utility function to return square of distance between p1 and p2. * @param p1 Co-ordinates of Point 1 . * @param p2 Co-ordinates of Point 2 . * @returns square of the distance between p1 and p2. - *******************************************************************************/ + */ int distSq(Point p1, Point p2) { return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); } -/****************************************************************************** +/** * @brief To find orientation of ordered triplet (p, q, r). * @param p Co-ordinates of Point p . * @param q Co-ordinates of Point q . * @param r Co-ordinates of Point r . * @returns 0 --> p, q and r are collinear, 1 --> Clockwise, * 2 --> Counterclockwise - *******************************************************************************/ + */ int orientation(Point p, Point q, Point r) { int val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); @@ -110,13 +110,13 @@ int orientation(Point p, Point q, Point r) { return (val > 0) ? 1 : 2; // clock or counter-clock wise } -/****************************************************************************** +/** * @brief A function used by library function qsort() to sort an array of * points with respect to the first point * @param vp1 Co-ordinates of Point 1 . * @param vp2 Co-ordinates of Point 2 . * @returns -1 if Point 1 sorts before Point 2, 1 otherwise. - *******************************************************************************/ + */ int compare(const void *vp1, const void *vp2) { auto *p1 = static_cast(vp1); auto *p2 = static_cast(vp2); @@ -130,12 +130,12 @@ int compare(const void *vp1, const void *vp2) { return (o == 2) ? -1 : 1; } -/****************************************************************************** +/** * @brief Prints convex hull of a set of n points. * @param points vector of Point with co-ordinates. * @param size Size of the vector. * @returns vector of the Points forming the convex hull. - *******************************************************************************/ + */ std::vector convexHull(std::vector points, uint64_t size) { // Find the bottom-most point int ymin = points[0].y, min = 0; diff --git a/numerical_methods/durand_kerner_roots.cpp b/numerical_methods/durand_kerner_roots.cpp index a5afc6a0046..7f79c3cfc5a 100644 --- a/numerical_methods/durand_kerner_roots.cpp +++ b/numerical_methods/durand_kerner_roots.cpp @@ -50,7 +50,7 @@ * \param[in] coeffs coefficients of the polynomial * \param[in] x point at which to evaluate the polynomial * \returns \f$f(x)\f$ - **/ + */ std::complex poly_function(const std::valarray &coeffs, std::complex x) { double real = 0.f, imag = 0.f; @@ -272,7 +272,7 @@ void test2() { << "\n"; } -/*** +/** * Main function. * The comandline input arguments are taken as coeffiecients of a *polynomial. For example, this command @@ -280,7 +280,7 @@ void test2() { * ./durand_kerner_roots 1 0 -4 * ``` * will find roots of the polynomial \f$1\cdot x^2 + 0\cdot x^1 + (-4)=0\f$ - **/ + */ int main(int argc, char **argv) { /* initialize random seed: */ std::srand(std::time(nullptr)); diff --git a/search/binary_search.cpp b/search/binary_search.cpp index ebe488e5658..54c28f584bb 100644 --- a/search/binary_search.cpp +++ b/search/binary_search.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/** * @file * @brief [Binary search * algorithm](https://en.wikipedia.org/wiki/Binary_search_algorithm) @@ -33,31 +33,30 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * @author Unknown author - *******************************************************************************/ - + */ #include /// for std::sort function #include /// for std::assert #include #include /// for IO operations #include /// for std::vector -/****************************************************************************** +/** * @namespace search * @brief Searching algorithms - *******************************************************************************/ + */ namespace search { -/****************************************************************************** +/** * @namespace binary_search * @brief Binary search searching algorihm - *******************************************************************************/ + */ namespace binary_search { -/****************************************************************************** +/** * @brief The main function which implements binary search * @param arr vector to be searched in * @param val value to be searched * @returns @param int index of val in vector arr - *******************************************************************************/ + */ uint64_t binarySearch(std::vector arr, uint64_t val) { uint64_t low = 0; // set the lowest point of the vector. uint64_t high = arr.size() - 1; // set the highest point of the vector. @@ -67,11 +66,9 @@ uint64_t binarySearch(std::vector arr, uint64_t val) { if (val == arr[m]) { return m; - } /**************************************************** - * if pivot point is the val, return it, - * else check if val is greater or smaller than pivot value - * and set the next pivot point accordingly. - ****************************************************/ + } /* if pivot point is the val, return it, + else check if val is greater or smaller than pivot value + and set the next pivot point accordingly. */ else if (val < arr[m]) { high = m - 1; } else { @@ -85,10 +82,10 @@ uint64_t binarySearch(std::vector arr, uint64_t val) { } // namespace search -/******************************************************************************* +/** * @brief Self-test implementation #1 * @returns void - *******************************************************************************/ + */ static void test1() { // testcase #1 // array = [1,3,5,7,9,8,6,4,2] , Value = 4 @@ -103,10 +100,10 @@ static void test1() { std::cout << "Passed!" << std::endl; } -/******************************************************************************* +/** * @brief Self-test implementation #2 * @returns void - *******************************************************************************/ + */ void test2() { // testcase #2 // array = [1,23,25,4,2] , Value = 25 @@ -120,10 +117,10 @@ void test2() { std::cout << "Passed!" << std::endl; } -/******************************************************************************* +/** * @brief Self-test implementation #3 * @returns void - *******************************************************************************/ + */ void test3() { // testcase #3 // array = [1,31,231,12,12,2,5,51,21,23,12,3] , Value = 5 @@ -137,10 +134,10 @@ void test3() { std::cout << "Passed!" << std::endl; } -/******************************************************************************* +/** * @brief Main function * @returns 0 on exit - *******************************************************************************/ + */ int main() { test1(); // run self-test implementation #1 test2(); // run self-test implementation #2 diff --git a/search/interpolation_search.cpp b/search/interpolation_search.cpp index 234d90ff698..86743c7ab1b 100644 --- a/search/interpolation_search.cpp +++ b/search/interpolation_search.cpp @@ -1,5 +1,5 @@ -/****************************************************************************** +/** * @file * @brief [Interpolation search * algorithm](https://en.wikipedia.org/wiki/interpolation_search) @@ -27,34 +27,33 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * @author Unknown author - *******************************************************************************/ - + */ #include /// for std::sort function #include /// for std::assert #include #include /// for IO operations #include /// for std::vector -/****************************************************************************** +/** * @namespace search * @brief Searching algorithms - *******************************************************************************/ + */ namespace search { -/****************************************************************************** +/** * @namespace interpolation_search * @brief Functions for the [Interpolation *Search](https://en.wikipedia.org/wiki/interpolation_search) algorithm *implementation - *******************************************************************************/ + */ namespace interpolation_search { -/****************************************************************************** +/** * @brief The main function which implements interpolation search * @param arr vector to be searched in * @param number value to be searched * @returns integer index of `number` in vector `arr` - *******************************************************************************/ + */ uint64_t interpolationSearch(const std::vector &arr, uint64_t number) { uint64_t size = arr.size(); @@ -94,10 +93,10 @@ uint64_t interpolationSearch(const std::vector &arr, } // namespace search -/******************************************************************************* +/** * @brief Self-test implementation * @returns void - *******************************************************************************/ + */ static void tests() { // testcase // array = [10, 12, 13, 16, 18, 19, 20, 21, 1, 2, 3, 4, 22, 23, 24, 33, 35, @@ -114,10 +113,10 @@ static void tests() { std::cout << "Passed!\n"; } -/******************************************************************************* +/** * @brief Main function * @returns 0 on exit - *******************************************************************************/ + */ int main() { tests(); // run self-test implementations return 0; diff --git a/sorting/selection_sort_iterative.cpp b/sorting/selection_sort_iterative.cpp index db293b88d03..151d162c1ea 100644 --- a/sorting/selection_sort_iterative.cpp +++ b/sorting/selection_sort_iterative.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/** * @file * @brief Implementation of the [Selection * sort](https://en.wikipedia.org/wiki/Selection_sort) implementation using @@ -26,25 +26,24 @@ * * @author [Lajat Manekar](https://github.com/Lazeeez) * @author Unknown author - *******************************************************************************/ + */ #include /// for std::is_sorted #include /// for std::assert #include #include /// for IO operations #include /// for std::vector -/****************************************************************************** +/** * @namespace sorting * @brief Sorting algorithms - *******************************************************************************/ + */ namespace sorting { -/****************************************************************************** +/** * @brief The main function which implements Selection sort * @param arr vector to be sorted * @param len length of vector to be sorted * @returns @param array resultant sorted vector - *******************************************************************************/ - + */ std::vector selectionSort(const std::vector &arr, uint64_t len) { std::vector array( @@ -69,10 +68,10 @@ std::vector selectionSort(const std::vector &arr, } } // namespace sorting -/******************************************************************************* +/** * @brief Self-test implementations * @returns void - *******************************************************************************/ + */ static void test() { // testcase #1 // [1, 0, 0, 1, 1, 0, 2, 1] returns [0, 0, 0, 1, 1, 1, 1, 2] @@ -117,10 +116,10 @@ static void test() { std::cout << "Passed" << std::endl; } -/******************************************************************************* +/** * @brief Main function * @returns 0 on exit - *******************************************************************************/ + */ int main() { test(); // run self-test implementations return 0;