text stringlengths 24 1.04M | metadata stringlengths 233 497 |
|---|---|
### File: math/armstrong_number.cpp
/**
* @file
* @brief Program to check if a number is an [Armstrong/Narcissistic
* number](https://en.wikipedia.org/wiki/Narcissistic_number) in decimal system.
*
* @details
* Armstrong number or [Narcissistic
* number](https://en.wikipedia.org/wiki/Narcissistic_number) is a nu... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/armstrong_number.cpp", "license": "mit", "size": 2664} |
### File: math/binary_exponent.cpp
/**
* @file
* @brief C++ Program to find Binary Exponent Iteratively and Recursively.
*
* Calculate \f$a^b\f$ in \f$O(\log(b))\f$ by converting \f$b\f$ to a
* binary number. Binary exponentiation is also known as exponentiation by
* squaring.
* @note This is a far better approa... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/binary_exponent.cpp", "license": "mit", "size": 1816} |
### File: math/binomial_calculate.cpp
/**
* @file
* @brief Program to calculate [Binomial
* coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient)
*
* @author [astronmax](https://github.com/astronmax)
*/
#include <cassert> /// for assert
#include <cstdint> /// for int32_t type
#include <cstdlib> ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/binomial_calculate.cpp", "license": "mit", "size": 2398} |
### File: math/check_amicable_pair.cpp
/**
* @file
* @brief A C++ Program to check whether a pair of numbers is an [amicable
* pair](https://en.wikipedia.org/wiki/Amicable_numbers) or not.
*
* @details
* An Amicable Pair is two positive integers such that the sum of the proper
* divisor for each number is equal ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/check_amicable_pair.cpp", "license": "mit", "size": 2473} |
### File: math/check_factorial.cpp
/**
* @file
* @brief A simple program to check if the given number is a
* [factorial](https://en.wikipedia.org/wiki/Factorial) of some number or not.
*
* @details A factorial number is the sum of k! where any value of k is a
* positive integer. https://www.mathsisfun.com/numbers... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/check_factorial.cpp", "license": "mit", "size": 1936} |
### File: math/check_prime.cpp
/**
* @file
* @brief
* A simple program to check if the given number is
* [Prime](https://en.wikipedia.org/wiki/Primality_test) or not.
* @details
* A prime number is any number that can be divided only by itself and 1. It
* must be positive and a whole number, therefore any prime ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/check_prime.cpp", "license": "mit", "size": 2735} |
### File: math/complex_numbers.cpp
/**
* @author tjgurwara99
* @file
*
* \brief An implementation of Complex Number as Objects
* \details A basic implementation of Complex Number field as a class with
* operators overloaded to accommodate (mathematical) field operations.
*/
#include <cassert>
#include <cmath>
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/complex_numbers.cpp", "license": "mit", "size": 9501} |
### File: math/double_factorial.cpp
/**
* @file
* @brief Compute [double
* factorial](https://en.wikipedia.org/wiki/Double_factorial): \f$n!!\f$
*
* Double factorial of a non-negative integer `n`, is defined as the product of
* all the integers from 1 to n that have the same parity (odd or even) as n.
* <br/>It ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/double_factorial.cpp", "license": "mit", "size": 1729} |
### File: math/eratosthenes.cpp
/**
* @file
* @brief [The Sieve of
* Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
* @details
* Store an array of booleans where a true value indicates that it's index is
* prime. For all the values in the array starting from 2 which we know is
* prime, we wal... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/eratosthenes.cpp", "license": "mit", "size": 3497} |
### File: math/eulers_totient_function.cpp
/**
* @file
* @brief Implementation of [Euler's
* Totient](https://en.wikipedia.org/wiki/Euler%27s_totient_function)
* @description
* Euler Totient Function is also known as phi function.
* \f[\phi(n) =
* \phi\left({p_1}^{a_1}\right)\cdot\phi\left({p_2}^{a_2}\right)\ldo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/eulers_totient_function.cpp", "license": "mit", "size": 2144} |
### File: math/extended_euclid_algorithm.cpp
/**
* @file
* @brief GCD using [extended Euclid's algorithm]
* (https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm)
*
* Finding coefficients of a and b ie x and y in Bézout's identity
* \f[\text{gcd}(a, b) = a \times x + b \times y \f]
* This is also used in ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/extended_euclid_algorithm.cpp", "license": "mit", "size": 2481} |
### File: math/factorial.cpp
/**
* @file
* @brief Find the [factorial](https://en.wikipedia.org/wiki/Factorial) of a
* given number
* @details Calculate factorial via recursion
* \f[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1
* = n\times(n-1)!\f]
* for example:
* \f$5! = 5\tim... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/factorial.cpp", "license": "mit", "size": 1500} |
### File: math/factorial_memoization.cpp
/**
* @file
* @brief [Factorial](https://en.wikipedia.org/wiki/Factorial) calculation using
* recursion and [memoization](https://en.wikipedia.org/wiki/Memoization)
* @details
* This program computes the factorial of a non-negative integer using recursion
* with memoizatio... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/factorial_memoization.cpp", "license": "mit", "size": 1930} |
### File: math/fast_power.cpp
/**
* @file
* @brief Faster computation for \f$a^b\f$
*
* Program that computes \f$a^b\f$ in \f$O(logN)\f$ time.
* It is based on formula that:
* 1. if \f$b\f$ is even:
* \f$a^b = a^\frac{b}{2} \cdot a^\frac{b}{2} = {a^\frac{b}{2}}^2\f$
* 2. if \f$b\f$ is odd: \f$a^b = a^\frac{b-1... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fast_power.cpp", "license": "mit", "size": 2401} |
### File: math/fibonacci.cpp
/**
* @file
* @brief n-th [Fibonacci
* number](https://en.wikipedia.org/wiki/Fibonacci_sequence).
*
* @details
* Naive recursive implementation to calculate the n-th Fibonacci number.
* \f[\text{fib}(n) = \text{fib}(n-1) + \text{fib}(n-2)\f]
*
* @see fibonacci_large.cpp, fibonacci_... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fibonacci.cpp", "license": "mit", "size": 1727} |
### File: math/fibonacci_fast.cpp
/**
* @file
* @brief Faster computation of Fibonacci series.
*
* @details
* An efficient way to calculate nth fibonacci number faster and simpler than
* \f$O(n\log n)\f$ method of matrix exponentiation. This works by using both
* recursion and dynamic programming. As 93rd fibona... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fibonacci_fast.cpp", "license": "mit", "size": 5911} |
### File: math/fibonacci_large.cpp
/**
* @file
* @brief Computes N^th Fibonacci number given as
* input argument. Uses custom build arbitrary integers library
* to perform additions and other operations.
*
* Took 0.608246 seconds to compute 50,000^th Fibonacci
* number that contains 10450 digits!
*
* \author [... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fibonacci_large.cpp", "license": "mit", "size": 3129} |
### File: math/fibonacci_matrix_exponentiation.cpp
/**
* @file
* @brief This program computes the N^th Fibonacci number in modulo mod
* input argument .
*
* Takes O(logn) time to compute nth Fibonacci number
*
*
* \author [villayatali123](https://github.com/villayatali123)
* \author [unknown author]()
* @see ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fibonacci_matrix_exponentiation.cpp", "license": "mit", "size": 3604} |
### File: math/fibonacci_sum.cpp
/**
* @file
* @brief An algorithm to calculate the sum of [Fibonacci
* Sequence](https://en.wikipedia.org/wiki/Fibonacci_number): \f$\mathrm{F}(n) +
* \mathrm{F}(n+1) + .. + \mathrm{F}(m)\f$
* @details An algorithm to calculate the sum of Fibonacci Sequence:
* \f$\mathrm{F}(n) + \... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/fibonacci_sum.cpp", "license": "mit", "size": 3821} |
### File: math/finding_number_of_digits_in_a_number.cpp
/**
* @author [aminos 🇮🇳](https://github.com/amino19)
* @file
*
* @brief [Program to count digits
* in an
* integer](https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods)
* @details It is a very basic math of finding number of di... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/finding_number_of_digits_in_a_number.cpp", "license": "mit", "size": 3337} |
### File: math/gcd_iterative_euclidean.cpp
/**
* @file
* @brief Compute the greatest common denominator of two integers using
* *iterative form* of
* [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm)
*
* @see gcd_recursive_euclidean.cpp, gcd_of_n_numbers.cpp
*/
#include <iostream>
#include... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/gcd_iterative_euclidean.cpp", "license": "mit", "size": 1418} |
### File: math/gcd_of_n_numbers.cpp
/**
* @file
* @brief This program aims at calculating the GCD of n numbers
*
* @details
* The GCD of n numbers can be calculated by
* repeatedly calculating the GCDs of pairs of numbers
* i.e. \f$\gcd(a, b, c)\f$ = \f$\gcd(\gcd(a, b), c)\f$
* Euclidean algorithm helps calcula... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/gcd_of_n_numbers.cpp", "license": "mit", "size": 3267} |
### File: math/gcd_recursive_euclidean.cpp
/**
* @file
* @brief Compute the greatest common denominator of two integers using
* *recursive form* of
* [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm)
*
* @see gcd_iterative_euclidean.cpp, gcd_of_n_numbers.cpp
*/
#include <iostream>
/**
* ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/gcd_recursive_euclidean.cpp", "license": "mit", "size": 1242} |
### File: math/integral_approximation.cpp
/**
* @file
* @brief Compute integral approximation of the function using [Riemann
* sum](https://en.wikipedia.org/wiki/Riemann_sum)
* @details In mathematics, a Riemann sum is a certain kind of approximation of
* an integral by a finite sum. It is named after ninetee... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/integral_approximation.cpp", "license": "mit", "size": 5614} |
### File: math/integral_approximation2.cpp
/**
* @file
* @brief [Monte Carlo
* Integration](https://en.wikipedia.org/wiki/Monte_Carlo_integration)
*
* @details
* In mathematics, Monte Carlo integration is a technique for numerical
* integration using random numbers. It is a particular Monte Carlo method that
* ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/integral_approximation2.cpp", "license": "mit", "size": 7355} |
### File: math/inv_sqrt.cpp
/**
* @file
* @brief Implementation of [the inverse square root
* Root](https://medium.com/hard-mode/the-legendary-fast-inverse-square-root-e51fee3b49d9).
* @details
* Two implementation to calculate inverse inverse root,
* from Quake III Arena (C++ version) and with a standard library... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/inv_sqrt.cpp", "license": "mit", "size": 3986} |
### File: math/iterative_factorial.cpp
/**
* @file
* @brief Iterative implementation of
* [Factorial](https://en.wikipedia.org/wiki/Factorial)
*
* @author [Renjian-buchai](https://github.com/Renjian-buchai)
*
* @details Calculates factorial iteratively.
* \f[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\t... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/iterative_factorial.cpp", "license": "mit", "size": 3123} |
### File: math/large_factorial.cpp
/**
* @file
* @brief Compute factorial of any arbitratily large number/
*
* \author [Krishna Vedala](https://github.com/kvedala)
* @see factorial.cpp
*/
#include <cstring>
#include <ctime>
#include <iostream>
#include "./large_number.h"
/** Test implementation for 10! Result m... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/large_factorial.cpp", "license": "mit", "size": 3388} |
### File: math/large_number.h
/**
* @file
* @brief Library to perform arithmatic operations on arbitrarily large
* numbers.
* \author [Krishna Vedala](https://github.com/kvedala)
*/
#ifndef MATH_LARGE_NUMBER_H_
#define MATH_LARGE_NUMBER_H_
#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cst... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/large_number.h", "license": "mit", "size": 8127} |
### File: math/largest_power.cpp
/**
* @file
* @brief Algorithm to find largest x such that p^x divides n! (factorial) using
* Legendre's Formula.
* @details Given an integer n and a prime number p, the task is to find the
* largest x such that p^x (p raised to power x) divides n! (factorial). This
* will be done... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/largest_power.cpp", "license": "mit", "size": 1972} |
### File: math/lcm_sum.cpp
/**
* @file
* @brief An algorithm to calculate the sum of LCM: \f$\mathrm{LCM}(1,n) +
* \mathrm{LCM}(2,n) + \ldots + \mathrm{LCM}(n,n)\f$
* @details An algorithm to calculate the sum of LCM: \f$\mathrm{LCM}(1,n) +
* \mathrm{LCM}(2,n) + \ldots + \mathrm{LCM}(n,n)\f$ where
* \f$\mathrm{LC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/lcm_sum.cpp", "license": "mit", "size": 2820} |
### File: math/least_common_multiple.cpp
/**
* Copyright 2020 @author tjgurwara99
* @file
*
* A basic implementation of LCM function
*/
#include <cassert>
#include <iostream>
/**
* Function for finding greatest common divisor of two numbers.
* @params two integers x and y whose gcd we want to find.
* @return ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/least_common_multiple.cpp", "license": "mit", "size": 2304} |
### File: math/linear_recurrence_matrix.cpp
/**
* @brief Evaluate recurrence relation using [matrix
* exponentiation](https://www.hackerearth.com/practice/notes/matrix-exponentiation-1/).
* @details
* Given a recurrence relation; evaluate the value of nth term.
* For e.g., For fibonacci series, recurrence series i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/linear_recurrence_matrix.cpp", "license": "mit", "size": 14774} |
### File: math/magic_number.cpp
/**
* @file
* @brief A simple program to check if the given number is a magic number or
* not. A number is said to be a magic number, if the sum of its digits are
* calculated till a single digit recursively by adding the sum of the digits
* after every addition. If the single digit... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/magic_number.cpp", "license": "mit", "size": 2453} |
### File: math/miller_rabin.cpp
/**
* Copyright 2020 @author tjgurwara99
* @file
*
* A basic implementation of Miller-Rabin primality test.
*/
#include <cassert>
#include <iostream>
#include <random>
#include <vector>
/**
* Function to give a binary representation of a number in reverse order
* @param num inte... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/miller_rabin.cpp", "license": "mit", "size": 5857} |
### File: math/modular_division.cpp
/**
* @file
* @brief An algorithm to divide two numbers under modulo p [Modular
* Division](https://www.geeksforgeeks.org/modular-division)
* @details To calculate division of two numbers under modulo p
* Modulo operator is not distributive under division, therefore
* we first ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/modular_division.cpp", "license": "mit", "size": 3789} |
### File: math/modular_exponentiation.cpp
/**
* @file
* @brief C++ Program for Modular Exponentiation Iteratively.
* @details The task is to calculate the value of an integer a raised to an
* integer exponent b under modulo c.
* @note The time complexity of this approach is O(log b).
*
* Example:
* (4^3) % 5 (w... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/modular_exponentiation.cpp", "license": "mit", "size": 2391} |
### File: math/modular_inverse_fermat_little_theorem.cpp
/**
* @file
* @brief C++ Program to find the modular inverse using [Fermat's Little
* Theorem](https://en.wikipedia.org/wiki/Fermat%27s_little_theorem)
*
* Fermat's Little Theorem state that \f[ϕ(m) = m-1\f]
* where \f$m\f$ is a prime number.
* \f{eqnarray... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/modular_inverse_fermat_little_theorem.cpp", "license": "mit", "size": 4200} |
### File: math/modular_inverse_simple.cpp
/**
* @file
* @brief Simple implementation of [modular multiplicative
* inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse)
*
* @details
* this algorithm calculates the modular inverse x^{-1} \mod y iteratively
*/
#include <cassert> /// for assert
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/modular_inverse_simple.cpp", "license": "mit", "size": 1529} |
### File: math/n_bonacci.cpp
/**
* @file
* @brief Implementation of the
* [N-bonacci](http://oeis.org/wiki/N-bonacci_numbers) series
*
* @details
* In general, in N-bonacci sequence,
* we generate sum of preceding N numbers from the next term.
*
* For example, a 3-bonacci sequence is the following:
* 0, 0, 1,... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/n_bonacci.cpp", "license": "mit", "size": 3212} |
### File: math/n_choose_r.cpp
/**
* @file
* @brief [Combinations](https://en.wikipedia.org/wiki/Combination) n choose r
* function implementation
* @details
* A very basic and efficient method of calculating
* choosing r from n different choices.
* \f$ \binom{n}{r} = \frac{n!}{r! (n-r)!} \f$
*
* @author [Tajme... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/n_choose_r.cpp", "license": "mit", "size": 2356} |
### File: math/ncr_modulo_p.cpp
/**
* @file
* @brief This program aims at calculating [nCr modulo
* p](https://cp-algorithms.com/combinatorics/binomial-coefficients.html).
* @details nCr is defined as n! / (r! * (n-r)!) where n! represents factorial
* of n. In many cases, the value of nCr is too large to fit in a ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/ncr_modulo_p.cpp", "license": "mit", "size": 6004} |
### File: math/number_of_positive_divisors.cpp
/**
* @file
* @brief C++ Program to calculate the number of positive divisors
*
* This algorithm uses the prime factorization approach.
* Any positive integer can be written as a product of its prime factors.
* <br/>Let \f$N = p_1^{e_1} \times p_2^{e_2} \times\cdots\... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/number_of_positive_divisors.cpp", "license": "mit", "size": 2944} |
### File: math/perimeter.cpp
/**
* @file
* @brief Implementations for the
* [perimeter](https://en.wikipedia.org/wiki/Perimeter) of various shapes
* @details The of a shape is the amount of 2D space it takes up.
* All shapes have a formula for their perimeter.
* These implementations support multiple return type... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/perimeter.cpp", "license": "mit", "size": 10202} |
### File: math/power_for_huge_numbers.cpp
/**
* @file
* @brief Compute powers of large numbers
*/
#include <iostream>
/** Maximum number of digits in output
* \f$x^n\f$ where \f$1 <= x,\; n <= 10000\f$ and overflow may happen
*/
#define MAX 100000
/** This function multiplies x
* with the number represented by... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/power_for_huge_numbers.cpp", "license": "mit", "size": 2111} |
### File: math/power_of_two.cpp
/**
* @file
* @brief Implementation to check whether a number is a power of 2 or not.
*
* @details
* This algorithm uses bit manipulation to check if a number is a power of 2 or
* not.
*
* ### Algorithm
* Let the input number be n, then the bitwise and between n and n-1 will let... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/power_of_two.cpp", "license": "mit", "size": 2840} |
### File: math/prime_factorization.cpp
/**
* @file
* @brief Prime factorization of positive integers
*/
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
/** Declaring variables for maintaing prime numbers and to check whether a
* number is prime or not
*/
bool isprime[1000006];
/** l... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/prime_factorization.cpp", "license": "mit", "size": 1747} |
### File: math/prime_numbers.cpp
/**
* @file
* @brief Get list of prime numbers
* @see primes_up_to_billion.cpp sieve_of_eratosthenes.cpp
*/
#include <iostream>
#include <vector>
/** Generate an increasingly large number of primes
* and store in a list
*/
std::vector<int> primes(size_t max) {
std::vector<int... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/prime_numbers.cpp", "license": "mit", "size": 951} |
### File: math/primes_up_to_billion.cpp
/**
* @file
* @brief Compute prime numbers upto 1 billion
* @see prime_numbers.cpp sieve_of_eratosthenes.cpp
*/
#include <cstring>
#include <iostream>
/** array to store the primes */
char prime[100000000];
/** Perform Sieve algorithm */
void Sieve(int64_t n) {
memset(p... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/primes_up_to_billion.cpp", "license": "mit", "size": 881} |
### File: math/quadratic_equations_complex_numbers.cpp
/**
* @file
* @brief Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
*
* @author [Renjian-buchai](https://github.com/Renjian-buchai)
*
* @description Calculates any quadratic equation in form ax^2 + bx + c.
*
* Quadratic equation:
* x ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/quadratic_equations_complex_numbers.cpp", "license": "mit", "size": 6373} |
### File: math/realtime_stats.cpp
/**
* \file
* \brief Compute statistics for data entered in rreal-time
*
* This algorithm is really beneficial to compute statistics on data read in
* realtime. For example, devices reading biometrics data. The algorithm is
* simple enough to be easily implemented in an embedded ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/realtime_stats.cpp", "license": "mit", "size": 5498} |
### File: math/sieve_of_eratosthenes.cpp
/**
* @file
* @brief Prime Numbers using [Sieve of
* Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
* @details
* Sieve of Eratosthenes is an algorithm that finds all the primes
* between 2 and N.
*
* Time Complexity : \f$O(N \cdot\log \log N)\f$
* <... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/sieve_of_eratosthenes.cpp", "license": "mit", "size": 4121} |
### File: math/sqrt_double.cpp
/**
* @file
* @brief Calculate the square root of any positive real number in \f$O(\log
* N)\f$ time, with precision fixed using [bisection
* method](https://en.wikipedia.org/wiki/Bisection_method) of root-finding.
*
* @see Can be implemented using faster and better algorithms like
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/sqrt_double.cpp", "license": "mit", "size": 1261} |
### File: math/string_fibonacci.cpp
/**
* @file
* @brief This Programme returns the Nth fibonacci as a string.
*
* The method used is manual addition with carry and placing it in a string
* which is called string addition This makes it have no bounds or limits
*
* @see fibonacci_large.cpp, fibonacci_fast.cpp, fi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/string_fibonacci.cpp", "license": "mit", "size": 2054} |
### File: math/sum_of_binomial_coefficient.cpp
/**
* @file
* @brief Algorithm to find sum of binomial coefficients of a given positive
* integer.
* @details Given a positive integer n, the task is to find the sum of binomial
* coefficient i.e nC0 + nC1 + nC2 + ... + nCn-1 + nCn By induction, we can
* prove ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/sum_of_binomial_coefficient.cpp", "license": "mit", "size": 1875} |
### File: math/sum_of_digits.cpp
/**
* Copyright 2020 @author iamnambiar
*
* @file
* \brief A C++ Program to find the Sum of Digits of input integer.
*/
#include <cassert>
#include <iostream>
/**
* Function to find the sum of the digits of an integer.
* @param num The integer.
* @return Sum of the digits of th... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/sum_of_digits.cpp", "license": "mit", "size": 1636} |
### File: math/vector_cross_product.cpp
/**
* @file
*
* @brief Calculates the [Cross Product](https://en.wikipedia.org/wiki/Cross_product) and the magnitude of two mathematical 3D vectors.
*
*
* @details Cross Product of two vectors gives a vector.
* Direction Ratios of a vector are the numeric parts of the give... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/vector_cross_product.cpp", "license": "mit", "size": 4724} |
### File: math/volume.cpp
/**
* @file
* @brief Implmentations for the [volume](https://en.wikipedia.org/wiki/Volume)
* of various 3D shapes.
* @details The volume of a 3D shape is the amount of 3D space that the shape
* takes up. All shapes have a formula to get the volume of any given shape.
* These implementati... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "math/volume.cpp", "license": "mit", "size": 8204} |
### File: numerical_methods/CMakeLists.txt
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. RELATIVE may makes it easier to extract an executable name
# automatically.
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
# file( GLOB APP_SOURCES ${CMAK... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/CMakeLists.txt", "license": "mit", "size": 852} |
### File: numerical_methods/babylonian_method.cpp
/**
* @file
* @brief [A babylonian method
* (BM)](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
* is an algorithm that computes the square root.
* @details
* This algorithm has an application in use case scenario where a ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/babylonian_method.cpp", "license": "mit", "size": 2884} |
### File: numerical_methods/bisection_method.cpp
/**
* \file
* \brief Solve the equation \f$f(x)=0\f$ using [bisection
* method](https://en.wikipedia.org/wiki/Bisection_method)
*
* Given two points \f$a\f$ and \f$b\f$ such that \f$f(a)<0\f$ and
* \f$f(b)>0\f$, then the \f$(i+1)^\text{th}\f$ approximation is given... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/bisection_method.cpp", "license": "mit", "size": 2046} |
### File: numerical_methods/brent_method_extrema.cpp
/**
* \file
* \brief Find real extrema of a univariate real function in a given interval
* using [Brent's method](https://en.wikipedia.org/wiki/Brent%27s_method).
*
* Refer the algorithm discoverer's publication
* [online](https://maths-people.anu.edu.au/~brent... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/brent_method_extrema.cpp", "license": "mit", "size": 5718} |
### File: numerical_methods/composite_simpson_rule.cpp
/**
* @file
* @brief Implementation of the Composite Simpson Rule for the approximation
*
* @details The following is an implementation of the Composite Simpson Rule for
* the approximation of definite integrals. More info -> wiki:
* https://en.wikipedia.org/... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/composite_simpson_rule.cpp", "license": "mit", "size": 7861} |
### File: numerical_methods/durand_kerner_roots.cpp
/**
* @file
* \brief Compute all possible approximate roots of any given polynomial using
* [Durand Kerner
* algorithm](https://en.wikipedia.org/wiki/Durand%E2%80%93Kerner_method)
* \author [Krishna Vedala](https://github.com/kvedala)
*
* Test the algorithm onl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/durand_kerner_roots.cpp", "license": "mit", "size": 11243} |
### File: numerical_methods/false_position.cpp
/**
* \file
* \brief Solve the equation \f$f(x)=0\f$ using [false position
* method](https://en.wikipedia.org/wiki/Regula_falsi), also known as the Secant
* method
*
* \details
* First, multiple intervals are selected with the interval gap provided.
* Separate recu... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/false_position.cpp", "license": "mit", "size": 3986} |
### File: numerical_methods/fast_fourier_transform.cpp
/**
* @file
* @brief [A fast Fourier transform
* (FFT)](https://medium.com/@aiswaryamathur/understanding-fast-fouriertransform-from-scratch-to-solve-polynomial-multiplication-8018d511162f)
* is an algorithm that computes the
* discrete Fourier transform (... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/fast_fourier_transform.cpp", "license": "mit", "size": 5223} |
### File: numerical_methods/gaussian_elimination.cpp
/**
* \file
* \brief [Gaussian elimination
* method](https://en.wikipedia.org/wiki/Gaussian_elimination)
*/
#include <iostream>
/** Main function */
int main() {
int mat_size, i, j, step;
std::cout << "Matrix size: ";
std::cin >> mat_size;
// c... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/gaussian_elimination.cpp", "license": "mit", "size": 2161} |
### File: numerical_methods/golden_search_extrema.cpp
/**
* \file
* \brief Find extrema of a univariate real function in a given interval using
* [golden section search
* algorithm](https://en.wikipedia.org/wiki/Golden-section_search).
*
* \see brent_method_extrema.cpp
* \author [Krishna Vedala](https://github.c... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/golden_search_extrema.cpp", "license": "mit", "size": 4107} |
### File: numerical_methods/gram_schmidt.cpp
/**
* @file
* @brief [Gram Schmidt Orthogonalisation
* Process](https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process)
*
* @details
* Takes the input of Linearly Independent Vectors,
* returns vectors orthogonal to each other.
*
* ### Algorithm
* Take the firs... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/gram_schmidt.cpp", "license": "mit", "size": 9169} |
### File: numerical_methods/lu_decompose.cpp
/**
* \file
* \brief [LU decomposition](https://en.wikipedia.org/wiki/LU_decompositon) of a
* square matrix
* \author [Krishna Vedala](https://github.com/kvedala)
*/
#include <cassert>
#include <ctime>
#include <iomanip>
#include <iostream>
#include "./lu_decomposition... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/lu_decompose.cpp", "license": "mit", "size": 2587} |
### File: numerical_methods/lu_decomposition.h
/**
* @file lu_decomposition.h
* @author [Krishna Vedala](https://github.com/kvedala)
* @brief Functions associated with [LU
* Decomposition](https://en.wikipedia.org/wiki/LU_decomposition)
* of a square matrix.
*/
#pragma once
#include <iostream>
#include <valarray... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/lu_decomposition.h", "license": "mit", "size": 2726} |
### File: numerical_methods/midpoint_integral_method.cpp
/**
* @file
* @brief A numerical method for easy [approximation of
* integrals](https://en.wikipedia.org/wiki/Midpoint_method)
* @details The idea is to split the interval into N of intervals and use as
* interpolation points the xi for which it applies that... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/midpoint_integral_method.cpp", "license": "mit", "size": 7565} |
### File: numerical_methods/newton_raphson_method.cpp
/**
* \file
* \brief Solve the equation \f$f(x)=0\f$ using [Newton-Raphson
* method](https://en.wikipedia.org/wiki/Newton%27s_method) for both real and
* complex solutions
*
* The \f$(i+1)^\text{th}\f$ approximation is given by:
* \f[
* x_{i+1} = x_i - \frac... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/newton_raphson_method.cpp", "license": "mit", "size": 1634} |
### File: numerical_methods/ode_forward_euler.cpp
/**
* \file
* \authors [Krishna Vedala](https://github.com/kvedala)
* \brief Solve a multivariable first order [ordinary differential equation
* (ODEs)](https://en.wikipedia.org/wiki/Ordinary_differential_equation) using
* [forward Euler
* method](https://en.wikip... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/ode_forward_euler.cpp", "license": "mit", "size": 6783} |
### File: numerical_methods/ode_midpoint_euler.cpp
/**
* \file
* \authors [Krishna Vedala](https://github.com/kvedala)
* \brief Solve a multivariable first order [ordinary differential equation
* (ODEs)](https://en.wikipedia.org/wiki/Ordinary_differential_equation) using
* [midpoint Euler
* method](https://en.wik... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/ode_midpoint_euler.cpp", "license": "mit", "size": 6645} |
### File: numerical_methods/ode_semi_implicit_euler.cpp
/**
* \file
* \authors [Krishna Vedala](https://github.com/kvedala)
* \brief Solve a multivariable first order [ordinary differential equation
* (ODEs)](https://en.wikipedia.org/wiki/Ordinary_differential_equation) using
* [semi implicit Euler
* method](http... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/ode_semi_implicit_euler.cpp", "license": "mit", "size": 6779} |
### File: numerical_methods/qr_decompose.h
/**
* @file
* \brief Library functions to compute [QR
* decomposition](https://en.wikipedia.org/wiki/QR_decomposition) of a given
* matrix.
* \author [Krishna Vedala](https://github.com/kvedala)
*/
#ifndef NUMERICAL_METHODS_QR_DECOMPOSE_H_
#define NUMERICAL_METHODS_QR_D... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/qr_decompose.h", "license": "mit", "size": 6259} |
### File: numerical_methods/qr_decomposition.cpp
/**
* @file
* \brief Program to compute the [QR
* decomposition](https://en.wikipedia.org/wiki/QR_decomposition) of a given
* matrix.
* \author [Krishna Vedala](https://github.com/kvedala)
*/
#include <array>
#include <cmath>
#include <cstdlib>
#include <ctime>
#i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/qr_decomposition.cpp", "license": "mit", "size": 1443} |
### File: numerical_methods/qr_eigen_values.cpp
/**
* @file
* \brief Compute real eigen values and eigen vectors of a symmetric matrix
* using [QR decomposition](https://en.wikipedia.org/wiki/QR_decomposition)
* method.
* \author [Krishna Vedala](https://github.com/kvedala)
*/
#include <cassert>
#include <cmath>
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/qr_eigen_values.cpp", "license": "mit", "size": 8739} |
### File: numerical_methods/rungekutta.cpp
/**
* @{
* \file
* \brief [Runge Kutta fourth
* order](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) method
* implementation
*
* \author [Rudra Prasad Das](http://github.com/rudra697)
*
* \details
* It solves the unknown value of y
* for a given value o... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/rungekutta.cpp", "license": "mit", "size": 4088} |
### File: numerical_methods/successive_approximation.cpp
/**
* \file
* \brief Method of successive approximations using [fixed-point
* iteration](https://en.wikipedia.org/wiki/Fixed-point_iteration) method
*/
#include <cmath>
#include <iostream>
/** equation 1
* \f[f(y) = 3y - \cos y -2\f]
*/
static float eq(flo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "numerical_methods/successive_approximation.cpp", "license": "mit", "size": 906} |
### File: operations_on_datastructures/CMakeLists.txt
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. RELATIVE may makes it easier to extract an executable name
# automatically.
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
# file( GLOB APP_SOU... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/CMakeLists.txt", "license": "mit", "size": 764} |
### File: operations_on_datastructures/array_left_rotation.cpp
/**
* @file
* @brief Implementation for the [Array Left
* Rotation](https://www.javatpoint.com/program-to-left-rotate-the-elements-of-an-array)
* algorithm.
* @details Shifting an array to the left involves moving each element of the
* array so that i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/array_left_rotation.cpp", "license": "mit", "size": 5295} |
### File: operations_on_datastructures/array_right_rotation.cpp
/**
* @file
* @brief Implementation for the [Array right
* Rotation](https://www.javatpoint.com/program-to-right-rotate-the-elements-of-an-array)
* algorithm.
* @details Shifting an array to the right involves moving each element of the
* array so th... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/array_right_rotation.cpp", "license": "mit", "size": 5344} |
### File: operations_on_datastructures/circular_linked_list.cpp
/**
* @file
* @brief Implementation for a [Circular Linked
* List](https://www.geeksforgeeks.org/circular-linked-list/).
* @details A Circular Linked List is a variation on the regular linked list, in
* which the last node has a pointer to the first n... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/circular_linked_list.cpp", "license": "mit", "size": 10118} |
### File: operations_on_datastructures/circular_queue_using_array.cpp
#include <iostream>
using std::cin;
using std::cout;
int queue[10];
int front = 0;
int rear = 0;
int count = 0;
void Enque(int x) {
if (count == 10) {
cout << "\nOverflow";
} else {
queue[rear] = x;
rear = (rear + 1)... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/circular_queue_using_array.cpp", "license": "mit", "size": 1035} |
### File: operations_on_datastructures/get_size_of_linked_list.cpp
#include <iostream>
class Node {
public:
int val;
Node *next;
Node(int v, Node *n) : val(v), next(n) {} // Default constructor for Node
};
int getSize(Node *root) {
if (root == NULL) {
return 0;
}
// Each node will r... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/get_size_of_linked_list.cpp", "license": "mit", "size": 1396} |
### File: operations_on_datastructures/inorder_successor_of_bst.cpp
/**
* @file
* @brief An implementation for finding the [Inorder successor of a binary
* search tree](https://www.youtube.com/watch?v=5cPbNCrdotA) Inorder
* successor of a node is the next node in Inorder traversal of the Binary Tree.
* Inorder Suc... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/inorder_successor_of_bst.cpp", "license": "mit", "size": 14652} |
### File: operations_on_datastructures/intersection_of_two_arrays.cpp
/**
* @file
* @brief Implementation for the [Intersection of two sorted
* Arrays](https://en.wikipedia.org/wiki/Intersection_(set_theory))
* algorithm.
* @details The intersection of two arrays is the collection of all the elements
* that are c... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/intersection_of_two_arrays.cpp", "license": "mit", "size": 7090} |
### File: operations_on_datastructures/reverse_a_linked_list_using_recusion.cpp
#include <iostream>
using namespace std;
struct node {
int val;
node *next;
};
node *start;
void insert(int x) {
node *t = start;
if (start != NULL) {
while (t->next != NULL) {
t = t->next;
}
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/reverse_a_linked_list_using_recusion.cpp", "license": "mit", "size": ... |
### File: operations_on_datastructures/reverse_binary_tree.cpp
/**
* @file
* @brief Implementation for the [Reversing a Binary
* Tree](https://www.geeksforgeeks.org/reverse-tree-path/) recursively
* algorithm.
* @details A binary tree can be reversed by swapping the left and
* right child of a node at each node, ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/reverse_binary_tree.cpp", "license": "mit", "size": 8994} |
### File: operations_on_datastructures/selectionsortlinkedlist.cpp
#include <iostream>
using namespace std;
// node defined
class node {
public:
int data;
node *link;
node(int d) {
data = d;
link = NULL;
}
};
// printing the linked list
void print(node *head) {
node *current = hea... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/selectionsortlinkedlist.cpp", "license": "mit", "size": 6285} |
### File: operations_on_datastructures/trie_multiple_search.cpp
/**
* @file
* @brief [Trie
* datastructure](https://iq.opengenus.org/autocomplete-using-trie-data-structure/)
* with search variants
* @details
* This provides multiple variants of search functions
* on a trie structure utilizing STL. The tri... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/trie_multiple_search.cpp", "license": "mit", "size": 17119} |
### File: operations_on_datastructures/union_of_two_arrays.cpp
/**
* @file
* @brief Implementation for the [Union of two sorted
* Arrays](https://en.wikipedia.org/wiki/Union_(set_theory))
* algorithm.
* @details The Union of two arrays is the collection of all the unique elements
* in the first array, combined wi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "operations_on_datastructures/union_of_two_arrays.cpp", "license": "mit", "size": 7964} |
### File: others/CMakeLists.txt
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. RELATIVE may makes it easier to extract an executable name
# automatically.
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DI... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/CMakeLists.txt", "license": "mit", "size": 841} |
### File: others/buzz_number.cpp
/**
* @file
* @brief A buzz number is a number that is either divisible by 7 or has last
* digit as 7.
*/
#include <iostream>
/** main function */
int main() {
int n, t;
std::cin >> t;
while (t--) {
std::cin >> n;
if ((n % 7 == 0) || (n % 10 == 7))
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/buzz_number.cpp", "license": "mit", "size": 449} |
### File: others/decimal_to_binary.cpp
/**
* @file
* @brief Function to convert decimal number to binary representation
*/
#include <iostream>
/**
* This method converts the bit representation and stores it as a decimal
* number.
*/
void method1(int number) {
int remainder, binary = 0, var = 1;
do {
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/decimal_to_binary.cpp", "license": "mit", "size": 1231} |
### File: others/decimal_to_hexadecimal.cpp
/**
* @file
* @brief Convert decimal number to hexadecimal representation
*/
#include <iostream>
/**
* Main program
*/
int main(void) {
int valueToConvert = 0; // Holds user input
int hexArray[8]; // Contains hex values backwards
int i = 0; ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/decimal_to_hexadecimal.cpp", "license": "mit", "size": 969} |
### File: others/decimal_to_roman_numeral.cpp
/**
* @file
* @brief This Programme Converts a given decimal number in the range [0,4000)
* to both Lower case and Upper case Roman Numeral
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
/** This functions fills a string with character c,... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/decimal_to_roman_numeral.cpp", "license": "mit", "size": 3101} |
### File: others/easter.cpp
/*
* @file
* @brief Determines the [Date of
* Easter](https://en.wikipedia.org/wiki/Date_of_Easter) after 1582
*
* @details
* The date of Easter is determined in each year through a calculation known as
* "computus." Easter is celebrated on the first Sunday after the Paschal full
* m... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/TheAlgorithms-c-plus-plus", "path": "others/easter.cpp", "license": "mit", "size": 3601} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.