Skip to content

Repository files navigation

Overview

This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

The official Java source code is here.

Goals

Make a Rust implementation of the library so that a Rust programmer can follow this book easily or prefer to demonstrate the algorithms using Rust.

Try to keep the interface and variable name consistent with the original book while writing idiomatic rust code.

I hope that this project helped you understand why Rust is so wonderful and loved right now. Rust is proving to be a productive tool for reliable and efficient software. In Rust, the compiler plays a gatekeeper role by refusing to compile code with these elusive bugs, including concurrency bugs. By working alongside the compiler, you can spend your time focusing on the program’s logic rather than chasing down bugs. After you finish a day's work, go home and rest, can be at ease a good night's sleep, never worry about system crash.

Index

The table index follow.

1FUNDAMENTALS
1.2StackLIFO stack
1.3QueueFIFO queue
1.4LinkedListmultiset (linked list)
1.5QuickFindUFquick find
-QuickUnionUFquick union
-WeightedQuickUnionUFweighted quick union
-UFunion-by-rank with path halving
2SORTING
2.1insert.rsinsertion sort
2.2selection.rsselection sort
2.3shell.rsshellsort
2.4merge.rsMerge Sort
2.5quick.rsquicksort
-Quick3Wayquicksort with 3-way partitioning
2.6PQ::new_max_pqmax heap priority queue
-PQ::new_min_pqmin heap priority queue
-IndexPQ::new_min_pqindex min heap priority queue
-IndexPQ::new_max_pqindex max heap priority queue
-TopMFind the largest M elements
2.7floyd.rsheapsort
3SEARCHING
3.4rb2.rsred-black tree
3.6SparseVectorsparse vector
4GRAPHS
-Graphundirected graph
-DepthFirstSearchdepth-first search in a graph
-NonRecursiveDFSDFS in a graph (nonrecursive)
4.1DepthFirstPathspaths in a graph (DFS)
4.2BreadthFirstPathspaths in a graph (BFS)
4.3CCconnected components of a graph
-Bipartitebipartite or odd cycle (DFS)
-Cyclecycle in a graph
-SymbolGraphsymbol graph
-Digraphdirected graph
4.4DepthFirstPathspaths in a digraph (DFS)
-BreadthFirstPathspaths in a digraph (BFS)
-DirectedCyclecycle in a digraph
4.5Topologicaltopological order in a DAG
-TransitiveClosuretransitive closure
4.6KosarajuSCCstrong components (Kosaraju–Sharir)
-EWGraphedge-weighted graph
-LazyPrimMSTMST (lazy Prim)
4.7PrimMSTMST (Prim)
4.8KruskalMSTMST (Kruskal)
-EdgeWeightedDigraphCycleedge-weighted digraph
4.9DijkstraSPshortest paths (Dijkstra)
-DijkstraAllPairsSPall-pairs shortest paths
4.10AcyclicSPshortest paths in a DAG
-AcyclicLPlongest paths in a DAG
-CPMcritical path method
4.11BellmanFordSPshortest paths (Bellman–Ford)
-Arbitragearbitrage detection
5STRINGS
-Alphabetalphabet
-count.rsalphabet client
5.1LSDLSD radix sort
5.2MSDMSD radix sort
5.3Quick3String3-way string quicksort
5.4TrieSTmultiway trie symbol table
5.5TSTternary search trie
5.6KMPsubstring search (Knuth–Morris–Pratt)

Running

# setup Rust Toolchain
make test

Roadmap

  • Implement algorithms in the textbook Algorithms, 4th Edition
  • Algorithms visualization (Easy to study and short learning curve)

Used by

Contributors

Languages