Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/TheAlgorithms/C-Plus-Plus
/ functions
Functions
2,100 in github.com/TheAlgorithms/C-Plus-Plus
⨍
Functions
2,100
◇
Types & classes
164
↓ 7 callers
Method
Is34Node
@brief Check if node is a 3-node or 4-node, this is useful when we * delete item from 2-3-4 tree * @return true if node is 3-node or 4-node,
data_structures/tree_234.cpp:85
↓ 7 callers
Method
SearchPresence
* @brief Function to check a word's presence in the trie (Basic) * @param key the string key to be searched in the trie * @return true if the key
operations_on_datastructures/trie_multiple_search.cpp:220
↓ 7 callers
Method
addEdge
* @brief Function that add an edge between two nodes or vertices of graph * * @param u is a node or vertex of graph * @param v is a node or vertex
graph/is_graph_bipartite.cpp:83
↓ 7 callers
Function
are_almost_equal
* @brief Compare two floating point numbers with a certain tolerance. * This is needed as with some values, the result (e.g.: -196.15) might be a bit
others/kelvin_to_celsius.cpp:40
↓ 7 callers
Function
argmax
machine_learning/vector_ops.hpp:307
↓ 7 callers
Function
bubble_sort
sorting/bubble_sort.cpp:72
↓ 7 callers
Method
contains
* @brief Recursive function to check if a value is in the BST. * * @param node The node to search from. * @param value The value to fin
data_structures/binary_search_tree2.cpp:177
↓ 7 callers
Method
contains
* @brief Doest bitset contains element x * * @param x position in bitset to check * @returns true if bit position x is 1 * @returns false if bit p
data_structures/bloom_filter.cpp:86
↓ 7 callers
Function
countBitsFlip
* @brief The main function implements count of bits flip required * @param A is the given number whose bits will be flipped to get number B * @param
bit_manipulation/count_bits_flip.cpp:43
↓ 7 callers
Function
determinant_lu
numerical_methods/lu_decomposition.h:90
↓ 7 callers
Function
duval
strings/duval.cpp:49
↓ 7 callers
Method
enqueue
data_structures/circular_queue_using_linked_list.cpp:32
↓ 7 callers
Function
fibonacci
* @brief Function to compute the n-th Fibonacci number * @param n the index of the Fibonacci number * @returns n-th element of the Fibonacci's seque
math/fibonacci.cpp:32
↓ 7 callers
Function
finding_number_of_digits_in_a_number
* @brief The main function that checks * the number of digits in a number. * TC : O(number of digits) * @param n the number to check its digits *
math/finding_number_of_digits_in_a_number.cpp:31
↓ 7 callers
Function
finding_number_of_digits_in_a_number_using_log
* @brief This function finds the number of digits * in constant time using logarithmic function * TC: O(1) * @param n the number to check its digit
math/finding_number_of_digits_in_a_number.cpp:54
↓ 7 callers
Function
gray_code_generation
* @brief The main function to generate n-bit Gray code * * @param n Number of bits * @return A vector that stores the n-bit Gray code */
bit_manipulation/gray_code.cpp:33
↓ 7 callers
Method
insert
* @brief Insert the new element in the list * @param val element that will be inserted * @returns void */
data_structures/list_array.cpp:143
↓ 7 callers
Method
insert
* @brief Inserts all the values from a vector into the Circular Linked List * @details Goes through each element in the vector sequentially, inse
operations_on_datastructures/circular_linked_list.cpp:146
↓ 7 callers
Function
insertionSort
sorting/insertion_sort.cpp:59
↓ 7 callers
Function
kelvin_to_celsius
* @brief Conversion from Kelvin to Celsius algorithm. * @param number the Celsius number that will be used to convert * @returns the Kelvin number c
others/kelvin_to_celsius.cpp:49
↓ 7 callers
Function
longest_increasing_subsequence_using_binary_search
search/longest_increasing_subsequence_using_binary_search.cpp:65
↓ 7 callers
Function
phiFunction
* @brief Function to calculate Euler's Totient * @param n the number to find the Euler's Totient of */
math/eulers_totient_function.cpp:41
↓ 7 callers
Method
pop_back
* @brief pop the last node in the linked list. */
others/lru_cache2.cpp:122
↓ 7 callers
Function
postfix_evaluation
* @brief Postfix Evaluation algorithm to compute the value from given input * array * @param input vector of strings consisting of numbers and opera
others/postfix_evaluation.cpp:97
↓ 7 callers
Method
predict_words
* @brief predict/recommend a word that starts with a given prefix * @param prefix string to search for * @returns list of recommended words
data_structures/trie_using_hashmap.cpp:188
↓ 7 callers
Function
print
* @brief Prints the values of a vector sequentially, ending with a newline * character. * @param array Reference to the array to be printed * @retu
operations_on_datastructures/union_of_two_arrays.cpp:31
↓ 7 callers
Method
push
data_structures/queue_using_two_stacks.cpp:54
↓ 7 callers
Function
remove
range_queries/mo.cpp:19
↓ 7 callers
Function
reverse
sorting/pancake_sort.cpp:43
↓ 6 callers
Method
GetItemLeftChild
* @brief Get left child of item at item_index * @param item_index index of the item whose left child to be get * @return left child of item
data_structures/tree_234.cpp:278
↓ 6 callers
Method
GetItemRightChild
* @brief Get right child of item at item_index * @param item_index index of the item whose right child to be get * @return right child of i
data_structures/tree_234.cpp:291
↓ 6 callers
Method
SetItem
* @brief Set item value at position of index * @param index the index of the item to set * @param new_item item value */
data_structures/tree_234.cpp:140
↓ 6 callers
Function
count_paths
* @brief Counts the number of paths from node `u` to node `v` in a directed graph * using Depth First Search (DFS) * * @param A adjace
graph/number_of_paths.cpp:67
↓ 6 callers
Method
cumulative_distribution
* @brief The cumulative distribution function * @details The sum of all probabilities up to (and including) k trials. * Basically CDF(k) = P
probability/geometric_dist.cpp:104
↓ 6 callers
Method
display
Display a list. and total element */
data_structures/cll/cll.cpp:17
↓ 6 callers
Function
dot_product
* Dot product function. * Takes 2 vectors along with their dimension as input and returns the dot * product. * @param x vector 1 * @param y vector
numerical_methods/gram_schmidt.cpp:59
↓ 6 callers
Method
erase
* Iteratively frees each node in the Circular Linked List from the heap */
operations_on_datastructures/circular_linked_list.cpp:126
↓ 6 callers
Function
fibo
* This function finds nth fibonacci number in a given modulus * @param n nth fibonacci number * @param mod modulo number */
math/fibonacci_matrix_exponentiation.cpp:25
↓ 6 callers
Function
find_idx
* @brief Utility function for finding index * @details Utility function for finding the position of a character in array * `chars` * @param c chara
ciphers/base64_encoding.cpp:90
↓ 6 callers
Method
get
* @brief get the value from i units from right and j units from left side * of the board * @param i integer denoting ith row * @param j
machine_learning/a_star_search.cpp:104
↓ 6 callers
Function
get_intersection
* @brief Gets the intersection of two sorted arrays, and returns them in a * vector. * @details An algorithm is used that compares the elements of t
operations_on_datastructures/intersection_of_two_arrays.cpp:49
↓ 6 callers
Method
get_level_order
* @brief Level order traversal of a tree consists of visiting its * elements, top to bottom, left to right. This function performs * level o
operations_on_datastructures/reverse_binary_tree.cpp:139
↓ 6 callers
Function
get_union
* @brief Gets the union of two sorted arrays, and returns them in a * vector. * @details An algorithm is used that compares the elements of the two
operations_on_datastructures/union_of_two_arrays.cpp:49
↓ 6 callers
Function
hashFxn
Hash a key * @param key key value to hash * @returns hash of the key */
hashing/quadratic_probing_hash_table.cpp:46
↓ 6 callers
Function
hashFxn
* @brief Hash a key. Uses the STL library's `std::hash()` function. * * @param key value to hash * @return hash value of the key */
hashing/double_hash_hash_table.cpp:47
↓ 6 callers
Function
hashFxn
* @brief Hash a key. Uses the STL library's `std::hash()` function. * * @param key value to hash * @return hash value of the key */
hashing/linear_probing_hash_table.cpp:46
↓ 6 callers
Method
insertKey
Inserts a new key 'k'
data_structures/binaryheap.cpp:55
↓ 6 callers
Function
insertionSort
sorting/insertion_sort_recursive.cpp:51
↓ 6 callers
Function
is_armstrong
* @brief Function to check whether the number is armstrong number or not. * @param number to be checked * @return `true` if the number is armstrong.
math/armstrong_number.cpp:43
↓ 6 callers
Function
is_factorial
* @brief Function to check if the given number is factorial of some number or * not. * @param n number to be checked. * @return true if number is a
math/check_factorial.cpp:28
↓ 6 callers
Function
iterativeFactorial
* @brief Calculates the factorial iteratively. * @param n Nth factorial. * @return Factorial. * @note 0! = 1. * @warning Maximum=20 because there
math/iterative_factorial.cpp:47
↓ 6 callers
Function
kmp
* @brief KMP algorithm to find a pattern in a text * @param pattern string pattern to search * @param text text in which to search * @returns the s
strings/knuth_morris_pratt.cpp:53
↓ 6 callers
Method
last
* @brief Utility function to find the last element of the list * @returns the last element of the list */
data_structures/reverse_a_linked_list.cpp:153
↓ 6 callers
Function
lcm
* Function for finding the least common multiple of two numbers. * @params integer x and y whose lcm we want to find. * @return lcm of x and y using
math/least_common_multiple.cpp:43
↓ 6 callers
Method
lengthOfLongestSubstring
* @brief Function to find the length of the longest substring without repeating characters. * @param s Input string. * @return Length of the
others/longest_substring_without_repeating_characters.cpp:44
↓ 6 callers
Method
mean
return sample mean computed till last sample */
math/realtime_stats.cpp:42
↓ 6 callers
Function
median_of_medians
* This function search the element in an array for the given index. * @param A array where numbers are saved * @param idx current index in array * @re
search/median_search.cpp:62
↓ 6 callers
Method
new_val
Constructor * \param[in] x new data sample */
math/realtime_stats.cpp:32
↓ 6 callers
Method
pop
* @brief Pops an element from the stack * * @return The popped element * @throws std::out_of_range if the stack is empty */
data_structures/stack_using_array.cpp:62
↓ 6 callers
Function
print
* @brief Prints the values of a vector sequentially, ending with a newline * character. * @param array Reference to the array to be printed * @retu
operations_on_datastructures/array_right_rotation.cpp:30
↓ 6 callers
Function
print
* @brief Prints the values of a vector sequentially, ending with a newline * character. * @param array Reference to the array to be printed * @retu
operations_on_datastructures/array_left_rotation.cpp:29
↓ 6 callers
Function
print
* @brief Prints the values of a vector sequentially, ending with a newline * character. * @param array Reference to the array to be printed * @retu
operations_on_datastructures/intersection_of_two_arrays.cpp:31
↓ 6 callers
Method
print
* @brief Prints all of the elements in the tree to stdout * level-by-level, using the get_level_order() function. * @returns void */
operations_on_datastructures/reverse_binary_tree.cpp:164
↓ 6 callers
Method
push
* @brief Pushes an element onto the stack * * @param element Element to push onto the stack */
data_structures/stack_using_array.cpp:48
↓ 6 callers
Method
put
* @brief upsert a key-value pair * @param key key of the key-value pair * @param value value of the key-value pair */
others/lru_cache2.cpp:145
↓ 6 callers
Method
put
* @brief upsert a key-value pair * @param key key of the key-value pair * @param value value of the key-value pair */
others/lfu_cache.cpp:174
↓ 6 callers
Function
save_u_matrix
* Create the distance matrix or * [U-matrix](https://en.wikipedia.org/wiki/U-matrix) from the trained * 3D weiths matrix and save to disk. * * \pa
machine_learning/kohonen_som_topology.cpp:142
↓ 6 callers
Method
search
* @brief Parent function of binarySearch and linearSearch methods * @param val element that will be searched * @return index of element in t
data_structures/list_array.cpp:97
↓ 6 callers
Function
show_array
sorting/bogo_sort.cpp:71
↓ 6 callers
Method
size
* @brief Get the number of values in the BST. * * @return std::size_t Number of values in the BST. */
data_structures/binary_search_tree2.cpp:314
↓ 6 callers
Method
sum
range_queries/fenwick_tree.cpp:90
↓ 6 callers
Method
top
* @brief Utility function to find the top element of the list * @returns the top element of the list */
data_structures/reverse_a_linked_list.cpp:142
↓ 6 callers
Method
update
* @brief Helper method for update method below * @param i The index of the current node * @param l The leftmost node of the current node
data_structures/segment_tree.cpp:62
↓ 6 callers
Method
variance
return data variance computed till last sample */
math/realtime_stats.cpp:45
↓ 5 callers
Method
UnionSet
* @brief Method that combines two disjoint sets to which i and j belongs to * and make a single set having a common representative. * @param
data_structures/dsu_path_compression.cpp:88
↓ 5 callers
Function
are_amicable
* @brief Function to check whether the pair is amicable or not. * @param x First number. * @param y Second number. * @return `true` if the pair is
math/check_amicable_pair.cpp:58
↓ 5 callers
Function
binomialCoeffSum
* Function to calculate sum of binomial coefficients * @param n number * @return Sum of binomial coefficients of number */
math/sum_of_binomial_coefficient.cpp:27
↓ 5 callers
Function
can_jump
* @brief Checks whether the given element (default is `1`) can jump to the last * index. * @param nums array of numbers containing the maximum jump
greedy_algorithms/jump_game.cpp:42
↓ 5 callers
Function
compute_padded_size
* @brief Computes size of the padded input * @param input Input string * @return size_t Size of the padded input */
hashing/sha256.cpp:143
↓ 5 callers
Method
createNewNode
* @brief will allocate the memory for a node and, along the data and return the * node. * @param data value that a particular node will contain.
others/iterative_tree_traversals.cpp:88
↓ 5 callers
Function
dfs
* //Recursive function/method to implement depth first traversal(dfs): * @param v vertices * @param vis array to keep track of visited nodes (boolea
graph/kosaraju.cpp:55
↓ 5 callers
Method
digitSeparationForwardOrder
* @brief Implementation of digitSeparationForwardOrder method. * * @param largeNumber The large number to separate digits from. * @retu
greedy_algorithms/digit_separation.cpp:68
↓ 5 callers
Method
digitSeparationReverseOrder
* @brief Implementation of digitSeparationReverseOrder method. * * @param largeNumber The large number to separate digits from. * @retu
greedy_algorithms/digit_separation.cpp:48
↓ 5 callers
Function
display
Displays the table * @returns None */
hashing/quadratic_probing_hash_table.cpp:142
↓ 5 callers
Function
display
Displays the table * @returns None */
hashing/double_hash_hash_table.cpp:143
↓ 5 callers
Function
display
Function to displays the table * @returns none */
hashing/linear_probing_hash_table.cpp:120
↓ 5 callers
Function
exponential_expected
* @brief the expected value of the exponential distribution * @returns \f[\mu = \frac{1}{\lambda}\f] */
probability/exponential_dist.cpp:37
↓ 5 callers
Function
exponential_std
* @brief the standard deviation of the exponential distribution * @returns \f[\sigma = \frac{1}{\lambda}\f] */
probability/exponential_dist.cpp:59
↓ 5 callers
Function
exponential_var
* @brief the variance of the exponential distribution * @returns \f[\sigma^2 = \frac{1}{\lambda^2}\f] */
probability/exponential_dist.cpp:48
↓ 5 callers
Function
fiboSum
* Function to compute sum of fibonacci sequence from n to m. * @param n start of sequence * @param m end of sequence * @returns uint64_t the sum of
math/fibonacci_sum.cpp:91
↓ 5 callers
Method
find_max
* @brief Recursive function to find the maximum value in the BST. * * @param node The node to search from. * @param ret_value Variable
data_structures/binary_search_tree2.cpp:53
↓ 5 callers
Method
find_min
* @brief Recursive function to find the minimum value in the BST. * * @param node The node to search from. * @param ret_value Variable
data_structures/binary_search_tree2.cpp:71
↓ 5 callers
Function
hash
* @brief Converts the string to bytestring and calls the main algorithm * @param message Plain character message to hash * @return void* Pointer to
hashing/sha1.cpp:211
↓ 5 callers
Function
integral_approx
* @brief Computes integral approximation * @param lb lower bound * @param ub upper bound * @param func function passed in * @param delta * @
math/integral_approximation.cpp:42
↓ 5 callers
Function
largestPower
* @brief Function to calculate largest power * @param n number * @param p prime number * @returns largest power */
math/largest_power.cpp:29
↓ 5 callers
Function
lcmSum
* Function to compute sum of euler totients in sumOfEulerTotient vector * @param num input number * @returns int Sum of LCMs, i.e. ∑LCM(i, num) from
math/lcm_sum.cpp:30
↓ 5 callers
Function
lower
* @brief function to convert a C++ string to lower case * @param word takes an std::string as input * @returns std::string */
search/text_search.cpp:19
↓ 5 callers
Function
magic_number
* Function to check if the given number is magic number or not. * @param n number to be checked. * @return if number is a magic number, returns true
math/magic_number.cpp:33
↓ 5 callers
Function
miller_rabin_primality_test
math/miller_rabin.cpp:125
↓ 5 callers
Function
mod_division
* @brief This function calculates modular division * @param a integer dividend * @param b integer divisor * @param p integer modulo * @return a/b
math/modular_division.cpp:75
← previous
next →
101–200 of 2,100, ranked by callers