3.3 KiB
Roadmap / Todo list
Because I am not familiar with Rust, so it will be a good practice
Goal: Learn Rust by implementing classic algorithms
Principle: start simple, index-based first, avoid lifetimes early
🔍 Search
1. Binary Search
- Implement iterative version
- Return
Option<usize> - Practice slice borrowing:
&[T]
Rust focus - usize - Option - bounds checking
Extensions - lower_bound - upper_bound - partition_point
🔃 Sort
2. Insertion Sort
- In-place sorting
- Good for understanding mutable slices
Rust focus - &mut [T] - index manipulation - borrow checker basics
3. Merge Sort
- Recursive implementation
- Use temporary
Vec
Rust focus - ownership vs borrowing - recursion - Vec allocation
4. Generic Sort
fn sort<T: Ord>(arr: &mut [T])
Rust focus - generics - trait bounds (Ord)
🧭 Graph
5. Graph Representation
Recommended structure:
type Graph = Vec<Vec<(usize, i64)>>;
Rust focus - tuple - type alias - index-based graph
6. BFS / DFS
- Implement using adjacency list
- Use queue / stack
Rust focus - VecDeque - mutable borrow scope control
7. Dijkstra
- Use
BinaryHeap - Implement min-heap with
Reverse
Rust focus - BinaryHeap - Reverse<T> - ownership in heap
elements
🌱 Extra (Optional but Recommended)
8. Union-Find (Disjoint Set)
- Path compression
- Union by rank
Rust focus - struct + impl - mutable state management
9. Tree Traversal
- Preorder / Inorder / Postorder
Rust focus - Option<Box<T>> - match exhaustiveness
🗂 Suggested Repository Structure
algorithms-in-rust/
├── src/
│ ├── search/
│ │ └── binary_search.rs
│ ├── sort/
│ │ ├── insertion.rs
│ │ └── merge.rs
│ ├── graph/
│ │ ├── bfs.rs
│ │ └── dijkstra.rs
│ ├── lib.rs
└── tests/
🧠 Implementation Notes
- Prefer index-based structures early
- Avoid
Rc<RefCell<T>>unless truly needed - If borrow checker complains:
- reduce scope
- split logic into smaller functions
🎯 Recommended Order
- Binary Search\
- Insertion Sort\
- Merge Sort\
- BFS\
- Dijkstra
After completing this list, you should be comfortable reading and writing most Rust algorithm code.