MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 2 callersMethodset_component
Finds the component index of a given node
graphs/boruvka.py:61
↓ 2 callersMethodset_matricies
(self, red=None, green=None, blue=None, red_edge=None, nir=None)
digital_image_processing/index_calculation.py:110
↓ 2 callersMethodset_tail
(self, node: Node)
data_structures/linked_list/doubly_linked_list_two.py:85
↓ 2 callersMethodshow_min
Returns the minimum distance from node u to node v. >>> g = Graph(3) >>> g.add_edge(0, 1, 3) >>> g.add_edge(1,
dynamic_programming/floyd_warshall.py:45
↓ 2 callersMethodsift_down
(self, idx, array)
data_structures/heap/min_heap.py:67
↓ 2 callersMethodsift_up
(self, idx)
data_structures/heap/min_heap.py:91
↓ 2 callersFunctionsigmoid
Mathematical function sigmoid takes a vector x of K real numbers as input and returns 1/ (1 + e^-x). https://en.wikipedia.org/wiki/Sigmoi
neural_network/activation_functions/swish.py:21
↓ 2 callersFunctionsigmoid_function
Return the sigmoid function of a float. >>> sigmoid_function(3.5) 0.9706877692486436 >>> sigmoid_function(3.5, True) -8.75
neural_network/simple_neural_network.py:11
↓ 2 callersFunctionsignature
Return a word's frequency-based signature. >>> signature("test") 'e1s1t2' >>> signature("this is a test") ' 3a1e1h1i2s3t3' >
strings/anagrams.py:8
↓ 2 callersFunctionsimplify_kmap
Simplify the Karnaugh map. >>> simplify_kmap(kmap=[[0, 1], [1, 1]]) "A'B + AB' + AB" >>> simplify_kmap(kmap=[[0, 0], [0, 0]]) ''
boolean_algebra/karnaugh_map_simplification.py:7
↓ 2 callersFunctionslow_reversible_numbers
Count the number of reversible numbers of given length. Iterate over possible digits considering parity of current sum remainder. >>> slo
project_euler/problem_145/sol1.py:21
↓ 2 callersFunctionsobel_filter
(image)
digital_image_processing/filters/sobel_filter.py:10
↓ 2 callersFunctionsolution
Returns the sum of the numbers on the diagonals in a n by n spiral formed in the same way. >>> solution(1001) 669171001 >>> solution(
project_euler/problem_028/sol1.py:23
↓ 2 callersFunctionsolution
Returns the number of paths possible in a n x n grid starting at top left corner going to bottom right corner and being able to move right an
project_euler/problem_015/sol1.py:12
↓ 2 callersFunctionsolve
Solve the grid.
data_structures/arrays/sudoku_solver.py:141
↓ 2 callersFunctionsolve_simultaneous
>>> solve_simultaneous([[1, 2, 3],[4, 5, 6]]) [-1.0, 2.0] >>> solve_simultaneous([[0, -3, 1, 7],[3, 2, -1, 11],[5, 1, -2, 12]]) [
maths/simultaneous_linear_equation_solver.py:57
↓ 2 callersFunctionsort
:param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by asc
sorts/intro_sort.py:137
↓ 2 callersFunctionsplit_input
>>> split_input("one two 31235three4four") [['one', 'two', '31235three4four']]
strings/string_switch_case.py:19
↓ 2 callersFunctionsplit_matrix
Given an even length matrix, returns the top_left, top_right, bot_left, bot_right quadrant. >>> split_matrix([[4,3,2,4],[2,3,1,1],[6,5,4
divide_and_conquer/strassen_matrix_multiplication.py:33
↓ 2 callersFunctionstandard_deviation
>>> standard_deviation(0.21) 0.458257569495584
maths/joint_probability_distribution.py:72
↓ 2 callersFunctionstrand_sort
Strand sort implementation source: https://en.wikipedia.org/wiki/Strand_sort :param arr: Unordered input list :param reverse: Descen
sorts/strand_sort.py:4
↓ 2 callersFunctionsum_of_digits
Calculate the sum of digit values in a positive integer converted to the given 'base'. Where 'base' ranges from 2 to 36. Examples:
maths/special_numbers/harshad_numbers.py:56
↓ 2 callersFunctiontest_all_segments
Test all possible segments
data_structures/binary_tree/non_recursive_segment_tree.py:143
↓ 2 callersFunctiontest_floor_ceil
Tests the floor and ceiling functions in the tree.
data_structures/binary_tree/red_black_tree.py:629
↓ 2 callersFunctiontest_insert
Test the insert() method of the tree correctly balances, colors, and inserts.
data_structures/binary_tree/red_black_tree.py:570
↓ 2 callersFunctiontest_insert_and_search
Tests searching through the tree for values.
data_structures/binary_tree/red_black_tree.py:591
↓ 2 callersFunctiontest_insert_delete
Test the insert() and delete() method of the tree, verifying the insertion and removal of elements, and the balancing of the tree.
data_structures/binary_tree/red_black_tree.py:607
↓ 2 callersFunctiontest_linear_kernel
(ax, cost)
machine_learning/sequential_minimum_optimization.py:527
↓ 2 callersFunctiontest_rbf_kernel
(ax, cost)
machine_learning/sequential_minimum_optimization.py:547
↓ 2 callersFunctiontest_rotations
Test that the rotate_left and rotate_right functions work.
data_structures/binary_tree/red_black_tree.py:526
↓ 2 callersFunctiontest_tree_chaining
Tests the three different tree chaining functions.
data_structures/binary_tree/red_black_tree.py:673
↓ 2 callersFunctiontest_tree_traversal
Tests the three different tree traversal functions.
data_structures/binary_tree/red_black_tree.py:657
↓ 2 callersFunctiontest_trie
()
data_structures/trie/trie.py:92
↓ 2 callersFunctionto_complex_case
Returns the string concatenated with the delimiter we provide. Parameters: @text: The string on which we want to perform operation @
strings/string_switch_case.py:44
↓ 2 callersFunctionto_simple_case
>>> to_simple_case("one two 31235three4four") 'OneTwo31235three4four' >>> to_simple_case("This should be combined") 'ThisShouldBeComb
strings/string_switch_case.py:27
↓ 2 callersMethodtop_show
(self)
graphs/multi_heuristic_astar.py:50
↓ 2 callersMethodtop_to_bottom
(self, heap, start, size, positions)
graphs/minimum_spanning_tree_prims.py:15
↓ 2 callersFunctiontotal_frequency_distribution
Returns frequency distribution of total >>> total_frequency_distribution(sides_number=6, dice_number=1) [0, 1, 1, 1, 1, 1, 1] >>> t
project_euler/problem_205/sol1.py:17
↓ 2 callersFunctiontotal_time
r""" Returns total time of the motion Formula: .. math:: \frac{2 v_0 \cdot \sin (\alpha)}{g} v_0 - \text{ini
physics/horizontal_projectile_motion.py:108
↓ 2 callersFunctiontranslate_message
(key: str, message: str, mode: str)
ciphers/simple_substitution_cipher.py:50
↓ 2 callersFunctiontranslate_message
(key: str, message: str, mode: str)
ciphers/vigenere_cipher.py:36
↓ 2 callersFunctiontranslate_message
>>> translate_message("QWERTYUIOPASDFGHJKLZXCVBNM","Hello World","encrypt") 'Pcssi Bidsm'
ciphers/mono_alphabetic_ciphers.py:6
↓ 2 callersFunctiontranspose
(matrix: list[list[int]])
matrix/rotate_matrix.py:64
↓ 2 callersFunctiontrapped_rainwater
The trapped_rainwater function calculates the total amount of rainwater that can be trapped given an array of bar heights. It uses a dyna
dynamic_programming/trapped_water.py:16
↓ 2 callersMethodtraverse
(self)
data_structures/binary_tree/segment_tree_other.py:204
↓ 2 callersMethodupdate
Update the winning vector. >>> SelfOrganizingMap().update([[1, 2, 3], [4, 5, 6]], [1, 2, 3], 1, 0.1) [[1, 2, 3], [3.7, 4.7,
machine_learning/self_organizing_map.py:24
↓ 2 callersMethodupdate
Update the values in the segment tree in the range [a,b] with the given value. >>> s = SegmentTree([1, 2, 3, 4, 5]) >>> s.up
data_structures/binary_tree/segment_tree.py:47
↓ 2 callersMethodupdate
update with O(lg n) (Normal segment tree without lazy update will take O(nlg n) for each update) update(1, 1, size, a, b, v)
data_structures/binary_tree/lazy_segment_tree.py:52
↓ 2 callersFunctionupdate_header
Update the header table with a node link. Args: node_to_test: The node to be updated in the header table. target_node: The n
machine_learning/frequent_pattern_growth.py:173
↓ 2 callersMethodupdate_key
(self, elem: T, weight: int)
graphs/minimum_spanning_tree_prims2.py:120
↓ 2 callersMethodupdate_waiting_time
This method updates waiting times of unfinished processes >>> P1 = Process("P1", 0, 53) >>> P2 = Process("P2", 0, 17)
scheduling/multi_level_feedback_queue.py:134
↓ 2 callersFunctionvalid
(p: TPos)
graphs/multi_heuristic_astar.py:123
↓ 2 callersFunctionvalidate_credit_card_number
Function to validate the given credit card number. >>> validate_credit_card_number('4111111111111111') 4111111111111111 is a valid credit
strings/credit_card_validator.py:55
↓ 2 callersMethodvalidate_indices
<method Matrix.validate_indicies> Check if given indices are valid to pick element from matrix. Example: >>> a = Matr
matrix/sherman_morrison.py:57
↓ 2 callersFunctionvec_gaussian
(img: np.ndarray, variance: float)
digital_image_processing/filters/bilateral_filter.py:20
↓ 2 callersFunctionvol_spheres_intersect
r""" Calculate the volume of the intersection of two spheres. The intersection is composed by two spherical caps and therefore its volume is
maths/volume.py:60
↓ 2 callersFunctionxor
>>> xor("01010101", "00001111") '01011010'
other/sdes.py:22
↓ 2 callersFunctionzero_vector
returns a zero-vector of size 'dimension'
linear_algebra/src/lib.py:196
↓ 1 callersFunction__decrypt_part
Convert each letter of the input string into their respective trigram values, join them and split them into three equal groups of strings w
ciphers/trifid_cipher.py:40
↓ 1 callersFunction__encrypt_part
Arrange the triagram value of each letter of `message_part` vertically and join them horizontally. >>> __encrypt_part('ASK', TEST_CH
ciphers/trifid_cipher.py:23
↓ 1 callersMethod__eq__
Checks if two polynomials are equal. >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p == q
maths/polynomials/single_indeterminate_operations.py:160
↓ 1 callersMethod__hash_double_function
(self, key, data, increment)
data_structures/hashing/double_hash.py:35
↓ 1 callersMethod__hash_function_2
(self, value, data)
data_structures/hashing/double_hash.py:27
↓ 1 callersMethod__init__
( self, initial_block_size: int = 8, capacity_factor: float = 0.75 )
data_structures/hashing/hash_map.py:41
↓ 1 callersMethod__insert
Insert a new node in Binary Search Tree with value label
data_structures/binary_tree/binary_search_tree.py:170
↓ 1 callersFunction__judge_point
(pt: bool, neighbours: list[list[bool]])
cellular_automata/game_of_life.py:78
↓ 1 callersMethod__len__
(self)
data_structures/linked_list/deque_doubly.py:34
↓ 1 callersMethod__make_key_list
Shuffles the ordered character choices by pivoting at breakpoints Breakpoints are the set of characters in the passcode eg:
ciphers/shuffled_shift_cipher.py:73
↓ 1 callersMethod__make_shift_key
sum() of the mutated list of ascii values of all characters where the mutated list is the one returned by __neg_pos()
ciphers/shuffled_shift_cipher.py:119
↓ 1 callersMethod__min_dist_top_down_dp
(self, m: int, n: int)
dynamic_programming/edit_distance.py:26
↓ 1 callersMethod__multiply
(self)
maths/radix2_fft.py:110
↓ 1 callersMethod__need_index_manager
This function builds an index control dictionary to track original ids/indices of processes when altered during execution of method "
other/bankers_algorithm.py:86
↓ 1 callersMethod__neg_pos
Mutates the list by changing the sign of each alternate element :param iterlist: takes a list iterable :return: the mutated
ciphers/shuffled_shift_cipher.py:47
↓ 1 callersMethod__passcode_creator
Creates a random password from the selection buffer of 1. uppercase letters of the English alphabet 2. lowercase letters of t
ciphers/shuffled_shift_cipher.py:59
↓ 1 callersMethod__pretty_data
Properly align display of the algorithm's solution
other/bankers_algorithm.py:197
↓ 1 callersMethod__processes_resource_summation
Check for allocated resources in line with each resource in the claim vector
other/bankers_algorithm.py:59
↓ 1 callersMethod__str__
>>> p = Polynomial(2, [1, 2, 3]) >>> print(p) 3x^2 + 2x + 1
maths/polynomials/single_indeterminate_operations.py:102
↓ 1 callersMethod__swap_down
Swap the element down
data_structures/heap/max_heap.py:38
↓ 1 callersMethod__swap_up
Swap the element up
data_structures/heap/max_heap.py:23
↓ 1 callersMethod__traversal
Pre-order traversal of nodes
data_structures/heap/binomial_heap.py:374
↓ 1 callersFunction_add_point_to_hull
Add a point to hull, removing collinear intermediate points.
geometry/jarvis_march.py:111
↓ 1 callersMethod_add_suffix
Adds a suffix to the suffix tree. Args: suffix (str): The suffix to add. index (int): The starting index of
data_structures/suffix_tree/suffix_tree.py:34
↓ 1 callersMethod_algorithm
(self)
graphs/edmonds_karp_multiple_source_and_sink.py:77
↓ 1 callersFunction_base10_to_85
(d: int)
ciphers/base85.py:8
↓ 1 callersFunction_base85_to_10
(digits: list)
ciphers/base85.py:12
↓ 1 callersFunction_bellman_ford
Bellman-Ford relaxation to compute potentials h[v] for all vertices. Raises ValueError if a negative weight cycle exists.
graphs/johnson.py:20
↓ 1 callersFunction_binomial_coefficient
Calculate the binomial coefficient C(total_elements, elements_to_choose) Args: total_elements (int): The total number of elements.
maths/special_numbers/bell_numbers.py:48
↓ 1 callersMethod_build_tree
(self, start, end)
data_structures/binary_tree/segment_tree_other.py:168
↓ 1 callersFunction_calculate
A small helper function for the recursion, mainly to have a clean interface for the solution() function below. It should get called with
project_euler/problem_191/sol1.py:31
↓ 1 callersMethod_calculate_gradient_from_pool
calculate the gradient from the data slice of pool layer pd_pool: list of matrix out_map: the shape of data slice(size_map*si
neural_network/convolution_neural_network.py:187
↓ 1 callersMethod_calculate_k_matrix
(self)
machine_learning/sequential_minimum_optimization.py:196
↓ 1 callersMethod_check
(self)
machine_learning/sequential_minimum_optimization.py:422
↓ 1 callersMethod_choose_a1
Choose first alpha Steps: 1: First loop over all samples 2: Second loop over all non-bound samples until no n
machine_learning/sequential_minimum_optimization.py:226
↓ 1 callersMethod_choose_alphas
(self)
machine_learning/sequential_minimum_optimization.py:220
↓ 1 callersFunction_collect_nodes_and_edges
(graph: adjacency)
graphs/johnson.py:9
↓ 1 callersMethod_collision_resolution
This method is a type of open addressing which is used for handling collision. In this implementation the concept of linear probing
data_structures/hashing/hash_table.py:179
↓ 1 callersMethod_compare_cards
(self, other: PokerHand)
project_euler/problem_054/sol1.py:226
↓ 1 callersFunction_construct_points
constructs a list of points from an array-like object of numbers Arguments --------- list_of_tuples: array-like object of type numb
divide_and_conquer/convex_hull.py:88
↓ 1 callersFunction_construct_solution
Recursively reconstructs one of the optimal subsets given a filled DP table and the vector of weights Parameters ---------- * `
dynamic_programming/knapsack.py:103
↓ 1 callersFunction_count_cross_inversions
Counts the inversions across two sorted arrays. And combine the two arrays into one sorted array For all 1<= i<=len(P) and for all 1 <= j
divide_and_conquer/inversions.py:77
← previousnext →601–700 of 3,909, ranked by callers