algorithms-edu 0.1.1

Algorithms for pedagogical demonstration
Documentation

Rusty Algorithms and Data Structures

This repository presents Rust implementation of common algorithms and data structures, most of which are based on William Fiset's Java implementation: https://github.com/williamfiset/Algorithms . I highly recommend his YouTube channel, where he explains many of these algorithms in detail using illustrations, animations and pseudocode.

In addition to re-implementing W. Fiset's algorithms, I also add original content that might be helpful, such as solutions of classical puzzles e.g. N-Queens and Sudoku.

Usage

The implementation details are explained in comments and docs and the example usage is implied in unit tests. To run tests:

cargo test

These algorithms and data structures are not designed for production usage, but might be directly applicable in competitve programming.

Recommended Environment

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 mods

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

pub fn push_back(&mut self, value: T);
pub fn pop_front(&mut self) -> Option<T>;

over

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.