This repository documents and implements 25 fundamental algorithms in C++ and Rust. The goal is to keep the code clean, simple, and well-documented. We are open to feedback and improvements!
25-Algorithms/
βββ cpp/ # C++ implementations
βββ rust/ # Rust implementations
βββ README.md # Documentation
βββ CMakeLists.txt (for C++ projects)
βββ Cargo.toml (for Rust projects)| Algorithm | C++ | Rust | Description |
|---|---|---|---|
| Linear Search | β | β | Searches for an element in an array |
| Binary Search | β | β | Searches in a shorted array using divide and conquer |
| Breadth First Search (BFS) | Graph traversal algorithm | ||
| Depth First Search (DFS) | Graph traversal algorithm | ||
| Insertion Sort | β | Sorting algorithm | |
| Selection Sort | β | Sorting algorithm | |
| Merge Sort | β | Sorting algorithm using divide and conquer | |
| Quick Sort | β | Efficient sorting using partitioning | |
| Heap Sort | β | Sorting using heap data structure | |
| Counting Sort | β | Non-comparative sorting algorithm | |
| Kruskal's Algorithm | Minimum spanning tree algorithm | ||
| Floyd Warshall Algorithm | Shortest path in weighted graphs | ||
| Dijkastra's Algorithm | Shortest path algorithm | ||
| Bellman Ford Algorithm | Shortest path with negative weights | ||
| Kadane's Algorithm | Maximum sum subarray | ||
| Lee Algorithm | Shortest path in a grid | ||
| Flood Fill Algorithm | Graph traversal used in image filling | ||
| Floyd's Cycle Detection Algorithm | Detects cycles in linked lists | ||
| Union Find Algorithm | Disjooint set data structure | ||
| Topological Sorting in a DAG | Ordering in Directed Acyclic Graphs | ||
| KMP Algorithm | String matching algorithm | ||
| Kahn's Topologiocal Sort Algorithm | Another way to order DAG | ||
| Huffman Coding Compression Algorithm | Data compression algorithm | ||
| Quickselect Algorithm | Selects k-th smallest element in an array | ||
| Boyer-Moore Majority Vote Algorithm | Finds majority element in an array | ||
| Euclid's Algorithm | Computes the greatest common divisor (GCD) | ||
| In, Pre, Post order Tree Traversal | Different ways to traverse tress |
For C++ (CMake Build)
mkdir build && cd build
cmake ..
make
./binary_search # Example: Run Binary SearchFor Rust (Cargo)
cargo run -p binary_search # Example: Run Binary Searchπ‘ Have suggestions or improvements? Feel free to contribute or open an issue!