# Rusty Algorithms & Data Structures for Learners
<!-- [![Crates.io](https://img.shields.io/crates/d/algorithms-edu.svg)](https://crates.io/crates/algorithms-edu) -->
[![Crates.io](https://img.shields.io/crates/v/algorithms-edu.svg)](https://crates.io/crates/algorithms-edu)
[![Crates.io](https://img.shields.io/crates/l/algorithms-edu.svg)](https://crates.io/crates/algorithms-edu)
![Continuous Integration](https://github.com/TianyiShi2001/Algorithms/workflows/CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/TianyiShi2001/Algorithms/badge.svg?branch=main)](https://coveralls.io/github/TianyiShi2001/Algorithms?branch=main)
![lines of code](https://img.shields.io/badge/lines%20of%20code-10731-blue)
This repository presents Rust implementations of common algorithms and data structures, many of which are based on William Fiset's Java implementation: https://github.com/williamfiset/Algorithms . I highly recommend [his YouTube channel](https://www.youtube.com/user/purpongie), where he explains many of these algorithms in detail using illustrations, animations and pseudocode. I recommend that you implement these algorithms by yourself before comparing them to my or William's implementations, since the best way to learn is by doing, and it's likely that you discover ways in which the code can be written in a more efficient, robust and/or readable way, in which case you're welcome to submit a PR!
I also write algorithms that's not yet available in William's repository. When I do so I attach references (most of which are freely accessible) that I used and hopefully they should be sufficient to guide you to write your own implementations.
<!-- In addition to implementing W. Fiset's algorithms, I also write solutions to competitive programming problems. Some representative problems are explained in `src/problems`, and there is also a `leetcode` folder for my leetcode solutions. Both are far from completion. particularly in Leetcode. Where appropriate, I will note, or `use`, the relevent algorithm/data structure(s) in this crate. -->
## Usage
The implementation details are explained in comments and docs and the example usage is implied in unit tests. To run tests:
```
cargo test
```
I use LaTeX to write some math expression in docs. To render them correctly in docs, run:
```
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps --open
```
or an alias for this command:
```
./doc
```
## Recommended Environment
- Editor: Visual Studio Code
- Extension: [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer)
This simple setup provides most features a decent IDE would provide (importantly, jump to definition and type labelling)
<!-- ## Rusticity
This is not a verbatim translation of W. Fiset's Java implementation. Instead, I try to make the code idiomatic in Rust, according to these rules:
### Avoid Long Names Using `mod`s
For example, perfer
```
crate::algo::graph::bfs::adjacency_list_iterative::fast_deque
```
over
```
com.williamfiset.algorithms.graphtheory.BreadthFirstSearchAdjacencyListIterativeFastQueue
```
### Custom Data Structures Have Unsurprising Method Names and Behaviour
Follow the conventions of `std` types as much as possible.
For example, when implementing a `Queue`, prefer
```rust
pub fn push_back(&mut self, value: T);
pub fn pop_front(&mut self) -> Option<T>;
```
over
```rust
pub fn enqueue(&mut self, value: T);
pub fn dequeue(&mut self) -> T;
// or
pub fn offer(&mut self, value: T);
pub fn poll(&mut self) -> T;
```
### Use `Option<T>` to Represent Nullable Values
Genrerally, `Option::None` is an idiomatic representation of `null`. This makes the code work better with the standard library and cause less surprises. -->
# Contents
## Search Algorithms
- Binary Search
- Interpolation Search
- Ternary Search
## Sort Algorithms
- Merge sort
- Selection sort
- Bubble sort
- Insertion sort
- Counting sort
- Heap sort
- Radix sort
- Bucket sort
- Quick sort
- Hoare partition
## Graph
### Graph Representations
- Adjacency Matrix (Weighted & Unweighted)
- Adjacency List (Weighted & Unweighted)
- Condensed Adjacency Matrix (Weighted)
### Fundamental Graph Algorithms
- Depth-first search (iterative and recursive)
- Breadth-first search (iterative)
### Tree Algorithms
- Tree representation: with or without pointer to parent
- Fundamentals (DFS, tree height, tree sum, etc.)
- Tree Center
- Tree rooting
- Tree isomorphism
- Lowest common ancestor (LCA)
### Minimum Spanning Tree/Forest
- Prim's Algorithm
- Kruskal's Algorithm
### Network Flow
- Ford-Fulkerson + DFS
- DFS with capacity scaling
- Edmonds-Karp Algorithm (BFS)
- Dinic's Algorithm (BFS + DFS)
### Shortest Path
- BFS (unweighted)
- DAG shortest path with topological sorting
- Dijkstra's algorithm (non-negative weights, SSSP)
- Bellman-Ford algorithm (SSSP)
- Floyd-Warshall algorithm (APSP)
### Others
- Bipartite check
- Topological sorting of DAG graphs and DAG shortest path
- Eulerian path/circuit
- Strongly connected components (Tarjan's algorithm)
## Data Structures
- Bit manipulation
- Priority queue (binary heap)
- Balanced tree
- AVL tree
- Disjoin set (union-find)
- Sparse table (range query) (generic)
- Quadtree
- k-dimensional tree (k-d tree)
## Machine Learning
### Clustering
- Hierarchical clustering (WIP, almost done)
### K Nearest Neighbour (KNN)
- in quad tree (docs/annotations WIP)
- in k-d tree (docs/annotations WIP)
## Math
- GCD
- Euclidean algorithm
- Coprime
- Extended euclidean algorithm
- LCM
- log2
- Prime numbers
- Prime check
- Sieve of Eratosthenes
- Prime factorization (Pollard's rho algorithm)
### Linear Algebra (docs/annotations WIP)
- Basics (matrix representation, matrix/vector arithmetics)
- Determinant of square matrix (Laplace expansion)
- Gauss-Jordan Elimination
- LU Decomposition
- Cholesky Decomposition
# Problems
## Dynamic Programming
- Edit distance
- Knapsack 0/1
## Back Tracking
- Sudoku
- N-Queens
## Graph
- Travelling salesman problem (brutal force & DP)
## Network Flow
- Mice and owls
没有合适的资源?快使用搜索试试~ 我知道了~
解释了在Rust中实现的算法_Rust_下载.zip
共152个文件
rs:138个
yml:2个
txt:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 145 浏览量
2023-04-30
10:23:17
上传
评论
收藏 1.53MB ZIP 举报
温馨提示
解释了在Rust中实现的算法_Rust_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
解释了在Rust中实现的算法_Rust_下载.zip (152个子文件)
doc 76B
.gitignore 359B
katex-header.html 1KB
LICENSE 1KB
README.md 6KB
leetcode.md 819B
graph.png 20KB
gen_leetcode_md.py 624B
li2016.rs 34KB
graph.rs 17KB
avl_tree.rs 17KB
li2016_read_only.rs 13KB
hierarchical.rs 12KB
quadtree.rs 10KB
improved.rs 9KB
doubly_linked.rs 9KB
rooting.rs 9KB
lca.rs 8KB
gaussian_elimination.rs 8KB
bfs.rs 7KB
kdtree.rs 7KB
eulerian_path.rs 7KB
linked_list.rs 7KB
sparse_table.rs 6KB
kmeans.rs 6KB
sudoku.rs 6KB
red_black_tree.rs 6KB
matrix.rs 6KB
sieve.rs 5KB
btree.rs 5KB
improved.rs 5KB
dinic.rs 5KB
prim.rs 5KB
floyd_warshall.rs 5KB
single.rs 5KB
dfs.rs 5KB
dp.rs 5KB
quadtree.rs 5KB
bitvec.rs 5KB
topological_sort.rs 5KB
nqueens.rs 4KB
generic.rs 4KB
network_flow.rs 4KB
ford_fulkerson_dfs.rs 4KB
elementary.rs 4KB
dfs_capacity_scaling.rs 4KB
kdtree.rs 4KB
bipartite_check.rs 4KB
dijkstra.rs 4KB
tarjan_scc.rs 4KB
union_find.rs 4KB
kruskal.rs 4KB
edmonds_karp.rs 4KB
center.rs 4KB
inverse.rs 4KB
tree.rs 3KB
ternary_search.rs 3KB
gcd.rs 3KB
heaparray.rs 3KB
binary_heap.rs 3KB
vector.rs 3KB
multiple.rs 3KB
vector_int.rs 3KB
naive.rs 3KB
markov_chain.rs 3KB
naive.rs 3KB
geometry.rs 3KB
height.rs 3KB
li2016.rs 3KB
knapsack.rs 3KB
tower_of_hanoi.rs 3KB
bellman_ford.rs 3KB
sherlock_holmes.rs 3KB
isomorphism.rs 2KB
lu.rs 2KB
sum.rs 2KB
linked_list.rs 2KB
sort.rs 2KB
binary_search.rs 2KB
linear_systems.rs 2KB
factorize.rs 2KB
single.rs 2KB
quick_sort.rs 2KB
queue.rs 2KB
suffix_array.rs 2KB
edit_distance.rs 2KB
reconstruct_string_from_lmers.rs 2KB
mice_and_owls.rs 2KB
linalg.rs 2KB
permutations.rs 2KB
radix_sort.rs 2KB
vector.rs 2KB
bit.rs 2KB
brute_force.rs 1KB
interpolation_search.rs 1KB
dag.rs 1KB
cholesky.rs 1KB
determinant.rs 1KB
heap_sort.rs 1KB
tangent.rs 1KB
共 152 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功