Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
► backtracking | |
graph_coloringg.cpp | Prints the assigned colors using Graph Coloring algorithm |
knight_tour.cpp | Knight's tour algorithm |
minimax.cpp | Returns which is the longest/shortest number using minimax algorithm |
n_queens.cpp | Eight Queens puzzle |
n_queens_all_solution_optimised.cpp | N queens all optimized |
nqueen_print_all_solutions.cpp | Eight Queens puzzle, printing all solutions |
rat_maze.cpp | Implements Rat in a Maze algorithm |
subarray_sum.cpp | Subset-sum (only continuous subsets) problem |
subset_sum.cpp | Implementation of the Subset Sum problem |
sudoku_solve.cpp | Sudoku Solver algorithm |
wildcard_matching.cpp | Implementation of the Wildcard Matching problem |
► bit_manipulation | |
count_bits_flip.cpp | Implementation to [Count number of bits to be flipped to convert A to B] (https://www.geeksforgeeks.org/count-number-of-bits-to-be-flipped-to-convert-a-to-b/) in an integer |
count_of_set_bits.cpp | Implementation to [count number of set bits of a number] (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an integer |
count_of_trailing_ciphers_in_factorial_n.cpp | Count the number of ciphers in n! implementation |
hamming_distance.cpp | Returns the Hamming distance between two integers |
set_kth_bit.cpp | Implementation to [From the right, set the Kth bit in the binary representation of N] (https://practice.geeksforgeeks.org/problems/set-kth-bit3724/1/) in an integer |
► ciphers | |
a1z26_cipher.cpp | Implementation of the A1Z26 cipher |
atbash_cipher.cpp | Atbash Cipher implementation |
caesar_cipher.cpp | Implementation of Caesar cipher algorithm |
elliptic_curve_key_exchange.cpp | Implementation of Elliptic Curve Diffie Hellman Key Exchange |
hill_cipher.cpp | Implementation of Hill cipher algorithm |
morse_code.cpp | Implementation of [Morse Code] (https://en.wikipedia.org/wiki/Morse_code) |
uint128_t.hpp | |
uint256_t.hpp | |
vigenere_cipher.cpp | Implementation of Vigenère cipher algorithm |
xor_cipher.cpp | Implementation of XOR cipher algorithm |
► cpu_scheduling_algorithms | |
fcfs_scheduling.cpp | Implementation of FCFS CPU scheduling algorithm |
► data_structures | |
► cll | |
cll.h | |
avltree.cpp | A simple tree implementation using nodes |
binary_search_tree.cpp | A simple tree implementation using structured nodes |
binary_search_tree2.cpp | A generic binary search tree implementation |
binaryheap.cpp | A C++ program to demonstrate common Binary Heap Operations |
disjoint_set.cpp | Disjoint Sets Data Structure (Disjoint Sets) |
dsu_path_compression.cpp | DSU (Disjoint sets) |
dsu_union_rank.cpp | DSU (Disjoint sets) |
linked_list.cpp | Implementation of singly linked list algorithm |
linkedlist_implentation_usingarray.cpp | Linked list implementation using Arrays |
list_array.cpp | Dynamic Array |
queue.h | |
queue_using_array.cpp | Implementation of Linear [Queue using array] (https://www.geeksforgeeks.org/array-implementation-of-queue-simple/) |
queue_using_two_stacks.cpp | |
reverse_a_linked_list.cpp | Implementation of Reversing a single linked list |
skip_list.cpp | Data structure for fast searching and insertion in \(O(\log n)\) time |
sparse_table.cpp | Implementation of Sparse Table for min() function |
stack.h | This class specifies the basic operation on a stack as a linked list |
tree_234.cpp | A demo 2-3-4 tree implementation |
trie_modern.cpp | A basic implementation of trie class to store only lower-case strings |
trie_tree.cpp | Implementation of Trie data structure for English alphabets in small characters |
trie_using_hashmap.cpp | Implementation of Trie data structure using HashMap for different characters and method for predicting words based on prefix |
► divide_and_conquer | |
karatsuba_algorithm_for_fast_multiplication.cpp | Implementation of the Karatsuba algorithm for fast multiplication |
► dynamic_programming | |
0_1_knapsack.cpp | Implementation of [0-1 Knapsack Problem] (https://en.wikipedia.org/wiki/Knapsack_problem) |
abbreviation.cpp | Implementation of Abbrievation |
coin_change_topdown.cpp | Minimum coins change problem is a problem used to find the minimum number of coins required to completely reach a target amount |
cut_rod.cpp | Implementation of cutting a rod problem |
house_robber.cpp | Implementation of House Robber Problem algorithm |
kadane2.cpp | Implementation of [Kadane Algorithm] (https://en.wikipedia.org/wiki/Kadane%27s_algorithm) |
longest_increasing_subsequence.cpp | Calculate the length of the longest increasing subsequence in an array |
longest_palindromic_subsequence.cpp | Program to find the Longest Palindormic Subsequence of a string |
minimum_edit_distance.cpp | Implementation of Minimum Edit Distance using Dynamic Programing |
palindrome_partitioning.cpp | Implements Palindrome Partitioning algorithm, giving you the minimum number of partitions you need to make |
shortest_common_supersequence.cpp | SCS is a string Z which is the shortest supersequence of strings X and Y (may not be continuous in Z, but order is maintained) |
word_break.cpp | Word Break Problem |
► geometry | |
graham_scan_functions.hpp | |
jarvis_algorithm.cpp | Implementation of Jarvis’s algorithm |
line_segment_intersection.cpp | Check whether two line segments intersect each other or not |
► graph | |
bidirectional_dijkstra.cpp | [Bidirectional Dijkstra Shortest Path Algorithm] (https://www.coursera.org/learn/algorithms-on-graphs/lecture/7ml18/bidirectional-dijkstra) |
breadth_first_search.cpp | Breadth First Search Algorithm (Breadth First Search) |
connected_components.cpp | [Graph Connected Components (Connected Components)] (https://en.wikipedia.org/wiki/Component_(graph_theory)) |
connected_components_with_dsu.cpp | Disjoint union |
depth_first_search.cpp | Depth First Search Algorithm (Depth First Search) |
depth_first_search_with_stack.cpp | Depth First Search Algorithm using Stack (Depth First Search Algorithm) |
dijkstra.cpp | [Graph Dijkstras Shortest Path Algorithm (Dijkstra's Shortest Path)] (https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) |
hamiltons_cycle.cpp | The implementation of Hamilton's cycle dynamic solution for vertices number less than 20 |
hopcroft_karp.cpp | Implementation of Hopcroft–Karp algorithm |
is_graph_bipartite.cpp | Algorithm to check whether a graph is bipartite |
lowest_common_ancestor.cpp | Data structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting |
travelling_salesman_problem.cpp | [Travelling Salesman Problem] (https://en.wikipedia.org/wiki/Travelling_salesman_problem) implementation |
► graphics | |
spirograph.cpp | Implementation of Spirograph |
► greedy_algorithms | |
jumpgame.cpp | Implementation of an algorithm to solve the jumping game problem |
► hashing | |
chaining.cpp | Implementation of hash chains |
double_hash_hash_table.cpp | Storage mechanism using double-hashed keys |
linear_probing_hash_table.cpp | Storage mechanism using linear probing hash keys |
md5.cpp | Simple C++ implementation of the MD5 Hashing Algorithm |
quadratic_probing_hash_table.cpp | Storage mechanism using quadratic probing hash keys |
sha1.cpp | Simple C++ implementation of the SHA-1 Hashing Algorithm |
► machine_learning | |
adaline_learning.cpp | Adaptive Linear Neuron (ADALINE) implementation |
kohonen_som_topology.cpp | Kohonen self organizing map (topological map) |
kohonen_som_trace.cpp | Kohonen self organizing map (data tracing) |
neural_network.cpp | Implementation of [Multilayer Perceptron] (https://en.wikipedia.org/wiki/Multilayer_perceptron) |
ordinary_least_squares_regressor.cpp | Linear regression example using Ordinary least squares |
vector_ops.hpp | Various functions for vectors associated with [NeuralNetwork (aka Multilayer Perceptron)] (https://en.wikipedia.org/wiki/Multilayer_perceptron) |
► math | |
approximate_pi.cpp | Implementation to calculate an estimate of the number π (Pi) |
area.cpp | Implementations for the area of various shapes |
armstrong_number.cpp | Program to check if a number is an Armstrong/Narcissistic number in decimal system |
binary_exponent.cpp | C++ Program to find Binary Exponent Iteratively and Recursively |
binomial_calculate.cpp | Program to calculate Binomial coefficients |
check_amicable_pair.cpp | A C++ Program to check whether a pair of number is amicable pair or not |
check_factorial.cpp | A simple program to check if the given number is a factorial of some number or not |
check_prime.cpp | Reduced all possibilities of a number which cannot be prime. Eg: No even number, except 2 can be a prime number, hence we will increment our loop with i+6 jumping and check for i or i+2 to be a factor of the number; if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num) |
complex_numbers.cpp | An implementation of Complex Number as Objects |
double_factorial.cpp | Compute double factorial: \(n!!\) |
eulers_totient_function.cpp | C++ Program to find Euler's Totient function |
extended_euclid_algorithm.cpp | GCD using [extended Euclid's algorithm] (https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm) |
factorial.cpp | C++ program to find factorial of given number |
fast_power.cpp | Faster computation for \(a^b\) |
fibonacci.cpp | Generate fibonacci sequence |
fibonacci_fast.cpp | Faster computation of Fibonacci series |
fibonacci_large.cpp | Computes N^th Fibonacci number given as input argument. Uses custom build arbitrary integers library to perform additions and other operations |
fibonacci_matrix_exponentiation.cpp | This program computes the N^th Fibonacci number in modulo mod input argument |
fibonacci_sum.cpp | An algorithm to calculate the sum of Fibonacci Sequence: \(\mathrm{F}(n) + \mathrm{F}(n+1) + .. + \mathrm{F}(m)\) |
finding_number_of_digits_in_a_number.cpp | [Program to count digits in an integer](https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods) |
gcd_iterative_euclidean.cpp | Compute the greatest common denominator of two integers using iterative form of Euclidean algorithm |
gcd_of_n_numbers.cpp | This program aims at calculating the GCD of n numbers by division method |
gcd_recursive_euclidean.cpp | Compute the greatest common denominator of two integers using recursive form of Euclidean algorithm |
integral_approximation.cpp | Compute integral approximation of the function using Riemann sum |
integral_approximation2.cpp | Monte Carlo Integration |
inv_sqrt.cpp | Implementation of the inverse square root Root |
large_factorial.cpp | Compute factorial of any arbitratily large number/ |
large_number.h | Library to perform arithmatic operations on arbitrarily large numbers |
largest_power.cpp | Algorithm to find largest x such that p^x divides n! (factorial) using Legendre's Formula |
lcm_sum.cpp | An algorithm to calculate the sum of LCM: \(\mathrm{LCM}(1,n) + \mathrm{LCM}(2,n) + \ldots + \mathrm{LCM}(n,n)\) |
least_common_multiple.cpp | |
magic_number.cpp | 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 comes out to be 1,then the number is a magic number |
miller_rabin.cpp | |
modular_division.cpp | An algorithm to divide two numbers under modulo p Modular Division |
modular_exponentiation.cpp | C++ Program for Modular Exponentiation Iteratively |
modular_inverse_fermat_little_theorem.cpp | C++ Program to find the modular inverse using Fermat's Little Theorem |
modular_inverse_simple.cpp | Simple implementation of modular multiplicative inverse |
n_bonacci.cpp | Implementation of the N-bonacci series |
n_choose_r.cpp | Combinations n choose r function implementation |
ncr_modulo_p.cpp | This program aims at calculating nCr modulo p |
number_of_positive_divisors.cpp | C++ Program to calculate the number of positive divisors |
perimeter.cpp | Implementations for the perimeter of various shapes |
power_for_huge_numbers.cpp | Compute powers of large numbers |
power_of_two.cpp | Implementation to check whether a number is a power of 2 or not |
prime_factorization.cpp | Prime factorization of positive integers |
prime_numbers.cpp | Get list of prime numbers |
primes_up_to_billion.cpp | Compute prime numbers upto 1 billion |
realtime_stats.cpp | Compute statistics for data entered in rreal-time |
sieve_of_eratosthenes.cpp | Get list of prime numbers using Sieve of Eratosthenes |
sqrt_double.cpp | Calculate the square root of any positive real number in \(O(\log N)\) time, with precision fixed using bisection method of root-finding |
string_fibonacci.cpp | This Programme returns the Nth fibonacci as a string |
sum_of_binomial_coefficient.cpp | Algorithm to find sum of binomial coefficients of a given positive integer |
sum_of_digits.cpp | A C++ Program to find the Sum of Digits of input integer |
vector_cross_product.cpp | Calculates the Cross Product and the magnitude of two mathematical 3D vectors |
volume.cpp | Implmentations for the volume of various 3D shapes |
► numerical_methods | |
babylonian_method.cpp | A babylonian method (BM) is an algorithm that computes the square root |
bisection_method.cpp | Solve the equation \(f(x)=0\) using bisection method |
brent_method_extrema.cpp | Find real extrema of a univariate real function in a given interval using Brent's method |
composite_simpson_rule.cpp | Implementation of the Composite Simpson Rule for the approximation |
durand_kerner_roots.cpp | Compute all possible approximate roots of any given polynomial using Durand Kerner algorithm |
false_position.cpp | Solve the equation \(f(x)=0\) using false position method, also known as the Secant method |
fast_fourier_transform.cpp | A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT) |
gaussian_elimination.cpp | Gaussian elimination method |
golden_search_extrema.cpp | Find extrema of a univariate real function in a given interval using golden section search algorithm |
gram_schmidt.cpp | Gram Schmidt Orthogonalisation Process |
inverse_fast_fourier_transform.cpp | An inverse fast Fourier transform (IFFT) is an algorithm that computes the inverse fourier transform |
lu_decompose.cpp | LU decomposition of a square matrix |
lu_decomposition.h | Functions associated with LU Decomposition of a square matrix |
midpoint_integral_method.cpp | A numerical method for easy approximation of integrals |
newton_raphson_method.cpp | Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions |
ode_forward_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using forward Euler method |
ode_midpoint_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method |
ode_semi_implicit_euler.cpp | Solve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler method |
qr_decompose.h | Library functions to compute QR decomposition of a given matrix |
qr_decomposition.cpp | Program to compute the QR decomposition of a given matrix |
qr_eigen_values.cpp | Compute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method |
rungekutta.cpp | Runge Kutta fourth order method implementation |
successive_approximation.cpp | Method of successive approximations using fixed-point iteration method |
► operations_on_datastructures | |
array_left_rotation.cpp | Implementation for the Array Left Rotation algorithm |
array_right_rotation.cpp | Implementation for the Array right Rotation algorithm |
circular_linked_list.cpp | Implementation for a Circular Linked List |
inorder_successor_of_bst.cpp | An implementation for finding the Inorder successor of a binary search tree Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the last node in Inorder traversal |
intersection_of_two_arrays.cpp | Implementation for the Intersection of two sorted Arrays algorithm |
reverse_binary_tree.cpp | Implementation for the Reversing a Binary Tree recursively algorithm |
trie_multiple_search.cpp | Trie datastructure with search variants |
union_of_two_arrays.cpp | Implementation for the Union of two sorted Arrays algorithm |
► others | |
buzz_number.cpp | A buzz number is a number that is either divisible by 7 or has last digit as 7 |
decimal_to_binary.cpp | Function to convert decimal number to binary representation |
decimal_to_hexadecimal.cpp | Convert decimal number to hexadecimal representation |
decimal_to_roman_numeral.cpp | This Programme Converts a given decimal number in the range [0,4000) to both Lower case and Upper case Roman Numeral |
fast_integer_input.cpp | Read integers from stdin continuously as they are entered without waiting for the \n character |
happy_number.cpp | A happy number is a number whose sum of digits is calculated until the sum is a single digit, and this sum turns out to be 1 |
iterative_tree_traversals.cpp | Iterative version of Preorder, Postorder, and preorder [Traversal of the Tree] (https://en.wikipedia.org/wiki/Tree_traversal) |
kadanes3.cpp | Efficient implementation for maximum contiguous subarray sum by Kadane's algorithm |
lru_cache.cpp | An implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies) |
matrix_exponentiation.cpp | Matrix Exponentiation |
palindrome_of_number.cpp | Check if a number is palindrome or not |
paranthesis_matching.cpp | Perform paranthesis matching |
pascal_triangle.cpp | Pascal's triangle implementation |
postfix_evaluation.cpp | Evaluation of Postfix Expression |
primality_test.cpp | Primality test implementation |
recursive_tree_traversal.cpp | Recursive version of Inorder, Preorder, and Postorder [Traversal of the Tree] (https://en.wikipedia.org/wiki/Tree_traversal) |
smallest_circle.cpp | Get centre and radius of the smallest circle that circumscribes given set of points |
sparse_matrix.cpp | |
spiral_print.cpp | Print the elements of a matrix traversing it spirally |
stairs_pattern.cpp | This program is use to print the following pattern |
tower_of_hanoi.cpp | Solve the Tower of Hanoi problem |
vector_important_functions.cpp | A C++ program to demonstrate working of std::sort(), std::reverse() |
► probability | |
addition_rule.cpp | Addition rule of probabilities |
bayes_theorem.cpp | Bayes' theorem |
binomial_dist.cpp | Binomial distribution example |
geometric_dist.cpp | Geometric Distribution |
poisson_dist.cpp | Poisson statistics |
windowed_median.cpp | An implementation of a median calculation of a sliding window along a data stream |
► range_queries | |
fenwick_tree.cpp | Fenwick tree |
heavy_light_decomposition.cpp | Heavy Light Decomposition implementation |
persistent_seg_tree_lazy_prop.cpp | Persistent segment tree with range updates (lazy propagation) |
prefix_sum_array.cpp | Prefix Sum Array data structure implementation |
segtree.cpp | Implementation of [Segment Tree] (https://en.wikipedia.org/wiki/Segment_tree) data structure |
sparse_table.cpp | Implementation of Sparse Table data structure |
► search | |
exponential_search.cpp | Exponential search algorithm |
fibonacci_search.cpp | Fibonacci search algorithm |
floyd_cycle_detection_algo.cpp | Implementation of Floyd's Cycle Detection algorithm |
hash_search.cpp | Hash Search Algorithm - Best Time Complexity Ω(1) |
interpolation_search2.cpp | Interpolation search algorithm |
jump_search.cpp | C++ program to implement Jump Search |
linear_search.cpp | Linear search algorithm |
median_search.cpp | Implementation of Median search algorithm. @cases from here |
saddleback_search.cpp | Implementation of Saddleback Algorithm for 2D arrays |
sublist_search.cpp | Implementation of the Sublist Search Algorithm |
ternary_search.cpp | Ternary search algorithm |
text_search.cpp | Search for words in a long textual paragraph |
► sorting | |
binary_insertion_sort.cpp | Binary Insertion Sort Algorithm (Insertion Sort) |
bogo_sort.cpp | Implementation of Bogosort algorithm |
bubble_sort.cpp | Bubble sort algorithm |
comb_sort.cpp | Comb Sort Algorithm (Comb Sort) |
count_inversions.cpp | Counting Inversions using Merge Sort |
cycle_sort.cpp | Implementation of Cycle sort algorithm |
dnf_sort.cpp | Implementation of the DNF sort implementation |
gnome_sort.cpp | Implementation of gnome sort algorithm |
heap_sort.cpp | Heap Sort Algorithm (heap sort) implementation |
insertion_sort.cpp | Insertion Sort Algorithm (Insertion Sort) |
merge_insertion_sort.cpp | Algorithm that combines insertion sort and merge sort. Wiki link |
merge_sort.cpp | Merege Sort Algorithm (MEREGE SORT) implementation |
non_recursive_merge_sort.cpp | |
pancake_sort.cpp | Pancake sort sorts a disordered stack of pancakes by flipping any number of pancakes using a spatula using minimum number of flips |
pigeonhole_sort.cpp | Implementation of [Pigeonhole Sort algorithm] (https://en.wikipedia.org/wiki/Pigeonhole_sort) |
quick_sort.cpp | Quick sort algorithm |
quick_sort_3.cpp | Implementation Details |
radix_sort2.cpp | Algorithm of Radix sort |
random_pivot_quick_sort.cpp | Implementation of the Random Pivot Quick Sort algorithm |
recursive_bubble_sort.cpp | This is an implementation of a recursive version of the Bubble sort algorithm |
selection_sort_recursive.cpp | Implementation of the Selection sort implementation using recursion |
shell_sort2.cpp | Shell sort algorithm |
strand_sort.cpp | Implementation of Strand Sort algorithm |
wave_sort.cpp | Implementation of the Wave sort algorithm |
wiggle_sort.cpp | [Wiggle Sort Algorithm] (https://leetcode.com/problems/wiggle-sort-ii/) Implementation |
► strings | |
brute_force_string_searching.cpp | String pattern search - brute force |
horspool.cpp | Horspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm) |
knuth_morris_pratt.cpp | The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) |
manacher_algorithm.cpp | Implementation of Manacher's Algorithm |
rabin_karp.cpp | The Rabin-Karp Algorithm for finding a pattern within a piece of text with complexity O(n + m) |
z_function.cpp | The Z function for finding occurences of a pattern within a piece of text with time and space complexity O(n + m) |