Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/TheAlgorithms/Rust
/ functions
Functions
2,908 in github.com/TheAlgorithms/Rust
⨍
Functions
2,908
◇
Types & classes
211
↓ 6 callers
Function
calculate_entropy
Calculate entropy of a set of labels
src/machine_learning/decision_tree.rs:21
↓ 6 callers
Method
child_mut
Returns a mutable reference to the left or right child.
src/data_structures/treap.rs:182
↓ 6 callers
Method
compress
Compresses the given text using the LZ77 algorithm. # Arguments `text` - The string to be compressed # Returns A vector of `Token`s representing t
src/compression/lz77.rs:121
↓ 6 callers
Method
decode
In case the encoding is invalid, `None` is returned
src/general/huffman_encoding.rs:197
↓ 6 callers
Method
delete
(&mut self, u: usize, v: usize)
src/graph/decremental_connectivity.rs:44
↓ 6 callers
Method
delete_ith
(&mut self, index: u32)
src/data_structures/linked_list.rs:146
↓ 6 callers
Function
divide_u64
(n: u64)
src/ciphers/tea.rs:48
↓ 6 callers
Method
encode
(&self, data: &[T])
src/general/huffman_encoding.rs:154
↓ 6 callers
Method
fitness
(&self)
src/general/genetic.rs:288
↓ 6 callers
Method
insert
(&mut self, key: K, value: V)
src/data_structures/hash_table.rs:30
↓ 6 callers
Method
insert
Inserts a new item (disjoint set) into the data structure.
src/data_structures/union_find.rs:33
↓ 6 callers
Method
iter_mut
'_ is the "explicitly elided lifetime" syntax of Rust
src/data_structures/stack_using_singly_linked_list.rs:85
↓ 6 callers
Function
jaro_winkler_distance
(str1: &str, str2: &str)
src/string/jaro_winkler_distance.rs:7
↓ 6 callers
Function
kth_smallest
Returns k-th smallest element of an array, i.e. its order statistics. Time complexity is O(n^2) in the worst case, but only O(n) on average. It mutate
src/searching/kth_smallest.rs:7
↓ 6 callers
Function
kth_smallest_heap
Returns k-th smallest element of an array. Time complexity is stably O(nlog(k)) in all cases Extra space is required to maintain the heap, and it does
src/searching/kth_smallest_heap.rs:13
↓ 6 callers
Function
left_rotate
(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>)
src/data_structures/rb_tree.rs:508
↓ 6 callers
Function
minimax
Minimize the actions of the opponent while maximizing the game state of the current player.
src/graph/depth_first_search_tic_tac_toe.rs:195
↓ 6 callers
Method
partial_cmp
(&self, other: &Self)
src/graph/astar.rs:18
↓ 6 callers
Method
predict
(&self, test_point: &[f64])
src/machine_learning/decision_tree.rs:319
↓ 6 callers
Method
prepare
(&mut self, max_number: usize)
src/math/linear_sieve.rs:26
↓ 6 callers
Method
print_matching
(&self)
src/graph/bipartite_matching.rs:53
↓ 6 callers
Method
query
(&mut self, range: Range<usize>)
src/data_structures/lazy_segment_tree.rs:44
↓ 6 callers
Method
resize
(&mut self)
src/data_structures/hash_table.rs:47
↓ 6 callers
Function
right_rotate
(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>)
src/data_structures/rb_tree.rs:543
↓ 6 callers
Method
search
(&self, searched_key: K)
src/data_structures/skip_list.rs:56
↓ 6 callers
Function
sum_of_years_digits_depreciation
Calculates depreciation using the **sum-of-years' digits (SYD)** method. This is an *accelerated* method: higher depreciation is charged in earlier y
src/financial/depreciation.rs:318
↓ 6 callers
Function
test_full
(size: u32)
src/data_structures/veb_tree.rs:304
↓ 6 callers
Function
to_block
(data: &[u8])
src/ciphers/tea.rs:77
↓ 6 callers
Function
top_down_merge_sort
(arr: &mut [T])
src/sorting/merge_sort.rs:22
↓ 6 callers
Function
tournament_sort
From Wikipedia: Tournament sort is a sorting algorithm. It improves upon the naive selection sort by using a priority queue to find the next element i
src/sorting/tournament_sort.rs:8
↓ 6 callers
Function
trifid_encrypt
Encrypts a message using the Trifid cipher. # Arguments `message` - The message to encrypt `alphabet` - The characters to be used for the cipher (mu
src/ciphers/trifid.rs:26
↓ 6 callers
Method
yin
(&self, frequencies: &[f64])
src/signal_analysis/yin.rs:60
↓ 5 callers
Function
assert_ranks_close
Assert that every node's rank is within `epsilon` of `expected`.
src/graph/page_rank.rs:135
↓ 5 callers
Function
base32_encode
Encodes the given bytes into base32. The function converts binary data into base32 format using the standard alphabet. Output is padded with '=' char
src/ciphers/base32.rs:32
↓ 5 callers
Method
ceil
Returns the smallest value in this tree larger than value
src/data_structures/binary_search_tree.rs:145
↓ 5 callers
Method
child_mut
Returns a mutable reference to the left or right child.
src/data_structures/avl_tree.rs:197
↓ 5 callers
Method
colinear_point_on_segment
p must be colinear with the segment
src/geometry/segment.rs:55
↓ 5 callers
Method
contains
(x: F, y: F)
src/math/elliptic_curve.rs:86
↓ 5 callers
Function
cross_product
Cross Product and Magnitude Calculation This program defines functions to calculate the cross product of two 3D vectors and the magnitude of a vector
src/math/vector_cross_product.rs:13
↓ 5 callers
Function
decrypt_part
Converts each letter of the input string into their respective trigram values, joins them and splits them into three equal groups of strings which are
src/ciphers/trifid.rs:109
↓ 5 callers
Method
find_components
(&mut self, adj: &[Vec<usize>])
src/graph/strongly_connected_components.rs:95
↓ 5 callers
Method
fit
Fits the SVC with training data # Arguments `observations` - Training feature vectors `classes` - Class labels (should be 1.0 or -1.0) # Errors Retu
src/machine_learning/support_vector_classifier.rs:145
↓ 5 callers
Function
get_majority_class
Get the majority class label
src/machine_learning/decision_tree.rs:144
↓ 5 callers
Method
get_parent
(&self, v: usize, i: usize)
src/graph/lowest_common_ancestor.rs:29
↓ 5 callers
Function
huffman_decode
Decodes a Huffman-encoded string # Arguments `encoded` - The binary string to decode `codes` - HashMap of character to binary code mappings # Retur
src/compression/huffman_encoding.rs:245
↓ 5 callers
Function
kosaraju
(graph: &Graph)
src/graph/kosaraju.rs:43
↓ 5 callers
Function
pancake_sort
(arr: &mut [T])
src/sorting/pancake_sort.rs:3
↓ 5 callers
Method
resize
(&mut self, new_size: usize)
src/math/bell_numbers.rs:59
↓ 5 callers
Function
run_length_encode
(text: &str)
src/compression/run_length_encoding.rs:3
↓ 5 callers
Method
search
(&self, key: K)
src/data_structures/hash_table.rs:39
↓ 5 callers
Function
smith_waterman
Performs the Smith-Waterman local sequence alignment algorithm. This function creates a scoring matrix using dynamic programming to find the optimal
src/dynamic_programming/smith_waterman.rs:101
↓ 5 callers
Function
solve_two_satisfiability
Returns an assignment that satisfies all the constraints, or a variable that makes such an assignment impossible.\ Variables should be numbered from 1
src/graph/two_satisfiability.rs:18
↓ 5 callers
Function
stable_matching
( men_preferences: &HashMap<String, Vec<String>>, women_preferences: &HashMap<String, Vec<String>>, )
src/greedy/stable_matching.rs:115
↓ 5 callers
Function
straight_line_depreciation
Calculates depreciation using the **straight-line** method. The depreciable cost is divided equally across every period. Formula: ```text annual_exp
src/financial/depreciation.rs:111
↓ 5 callers
Function
tree_sort
(arr: &mut Vec<T>)
src/sorting/tree_sort.rs:63
↓ 5 callers
Function
validate_common
( useful_years: u32, purchase_value: f64, residual_value: f64, )
src/financial/depreciation.rs:67
↓ 5 callers
Function
vector_magnitude
Function to calculate the magnitude of a vector
src/math/vector_cross_product.rs:21
↓ 5 callers
Function
wave_sort
Wave Sort Algorithm Wave Sort is a sorting algorithm that works in O(n log n) time assuming the sort function used works in O(n log n) time. It arran
src/sorting/wave_sort.rs:18
↓ 5 callers
Function
xor
(text: &str, key: u8)
src/ciphers/xor.rs:5
↓ 4 callers
Function
add_edge
(tree: &mut Graph<V>, a: V, b: V)
src/graph/prufer_code.rs:39
↓ 4 callers
Method
add_edge
(&mut self, u: usize, v: usize)
src/graph/tarjans_ssc.rs:14
↓ 4 callers
Function
aes_decrypt
(cipher_text: &[Byte], key: AesKey)
src/ciphers/aes.rs:263
↓ 4 callers
Function
aes_encrypt
(plain_text: &[Byte], key: AesKey)
src/ciphers/aes.rs:234
↓ 4 callers
Function
all_rotations
Generates all rotations of a string. # Arguments `s` - The string to rotate # Returns A vector containing all rotations of the input string # Exa
src/compression/burrows_wheeler_transform.rs:43
↓ 4 callers
Function
base16_encode
Base16 encoding and decoding implementation. Base16, also known as hexadecimal encoding, represents binary data using 16 ASCII characters (0-9 and A-
src/ciphers/base16.rs:31
↓ 4 callers
Function
binary_insertion_sort
(arr: &mut [T])
src/sorting/binary_insertion_sort.rs:18
↓ 4 callers
Function
cocktail_shaker_sort
(arr: &mut [T])
src/sorting/cocktail_shaker_sort.rs:1
↓ 4 callers
Method
consecutive_orientation
Returns the orientation of consecutive segments ab and bc.
src/geometry/point.rs:15
↓ 4 callers
Method
contains
(&self, item: &Item)
src/data_structures/probabilistic/bloom_filter.rs:46
↓ 4 callers
Function
convert_pressure
Convert pressure from one unit to another. This function accepts both `PressureUnit` enums and string identifiers. # Arguments `value` - The numeri
src/conversions/pressure.rs:225
↓ 4 callers
Function
cosine
Returns the value of cos, approximated with the given tolerance, for an angle 'x' in radians
src/math/trig_functions.rs:77
↓ 4 callers
Function
cycle_sort
(arr: &mut [i32])
src/sorting/cycle_sort.rs:3
↓ 4 callers
Function
decrypt
Decrypts a ciphertext using the RSA private key # Arguments `ciphertext` - The encrypted message `private_key` - The private key to use for decrypti
src/ciphers/rsa_cipher.rs:218
↓ 4 callers
Method
delete
(&mut self, searched_key: K)
src/data_structures/skip_list.rs:154
↓ 4 callers
Method
direction
(&self, p: &Point)
src/geometry/segment.rs:22
↓ 4 callers
Function
display_board
(board: &[Vec<Players>])
src/graph/depth_first_search_tic_tac_toe.rs:136
↓ 4 callers
Function
double_declining_balance_depreciation
Calculates depreciation using the **double-declining balance (DDB)** method. DDB is the most widely used form of the diminishing balance method. It
src/financial/depreciation.rs:386
↓ 4 callers
Function
encode
(message: &str)
src/ciphers/morse_code.rs:7
↓ 4 callers
Function
encrypt
Encrypts a message using the RSA public key # Arguments `message` - The plaintext message (must be less than n) `public_key` - The public key to use
src/ciphers/rsa_cipher.rs:192
↓ 4 callers
Function
exchange_sort
(arr: &mut [i32])
src/sorting/exchange_sort.rs:3
↓ 4 callers
Function
find_median
(numbers: &[f64])
src/math/interquartile_range.rs:8
↓ 4 callers
Method
find_set
Finds the representative (root) of the set containing `element` with path compression. Path compression ensures that future queries are faster by dir
src/graph/disjoint_set_union.rs:56
↓ 4 callers
Method
frequency
Returns the frequency of this node
src/compression/huffman_encoding.rs:64
↓ 4 callers
Function
from_integer
()
src/math/field.rs:325
↓ 4 callers
Function
generate_nearly_ordered_vec
(n: u32, swap_times: u32)
src/sorting/sort_utils.rs:21
↓ 4 callers
Function
generate_random_vec
(n: u32, range_l: i32, range_r: i32)
src/sorting/sort_utils.rs:7
↓ 4 callers
Function
get_frequency
(bytes: &[u8])
src/general/huffman_encoding.rs:239
↓ 4 callers
Method
height
Returns the height of the left or right subtree.
src/data_structures/avl_tree.rs:205
↓ 4 callers
Method
high
(&self, value: u32)
src/data_structures/veb_tree.rs:41
↓ 4 callers
Method
index
(&self, cluster: u32, offset: u32)
src/data_structures/veb_tree.rs:49
↓ 4 callers
Method
is_leaf
(&self)
src/data_structures/b_tree.rs:40
↓ 4 callers
Method
kernel_function
Computes the kernel function between two vectors
src/machine_learning/support_vector_classifier.rs:115
↓ 4 callers
Method
left_child_idx
Returns the index of the left child of the element at `idx`. # Parameters - `idx`: The index of the element. # Returns The index of the left child.
src/data_structures/heap.rs:184
↓ 4 callers
Function
list_subset
list all subset combinations of n element in given set of r element. This is a recursive function that collects all subsets of the set of size n with
src/dynamic_programming/subset_generation.rs:4
↓ 4 callers
Method
low
(&self, value: u32)
src/data_structures/veb_tree.rs:45
↓ 4 callers
Function
odd_even_sort
(arr: &mut [T])
src/sorting/odd_even_sort.rs:1
↓ 4 callers
Function
patience_sort
(arr: &mut [T])
src/sorting/patience_sort.rs:3
↓ 4 callers
Function
peak_signal_to_noise_ratio
Computes the PSNR in decibels (dB) between an original and a compressed image. # Arguments `original` - Pixel values of the original image (u8 slice,
src/compression/peak_signal_to_noise_ratio.rs:22
↓ 4 callers
Function
permute
Here's a basic (naive) implementation for generating permutations
src/general/permutations/naive.rs:6
↓ 4 callers
Method
prefix_query
Computes the sum of elements from the start of the tree up to a specified index. This operation efficiently calculates the prefix sum using the tree
src/data_structures/fenwick_tree.rs:87
← previous
next →
101–200 of 2,908, ranked by callers