Rust-algorithm-club - Learn algorithms and data structures with Rust

Overview

logo

Rust Algorithm Club

🚧 🚧 This repo is under construction. Most materials are written in Chinese. Check it out here if you are able to read Chinese.

Welcome to the Rust Algorithm Club! This repository was originally inspired by Swift Algorithm Club. All algorithms here would be explained and implemented in Rust programming language! You can find out more on the Rust Algorithm Club main site. Just pick up some algorithms you are interested in and start learning. If you are brave enough, we recommend you the auto-generated API documentation. Go and fight with the source code.

This project along with its source code are on GitHub and we are looking forward to your contributions.

Rust Edition Build Status Documentation

General Concepts

Algorithms

Searching

Sorting

Simple sorts:

Efficient sorts:

Hybrid sorts (more efficient):

Special-purpose sorts:

Data Structures

Stack and Queue

Linked List

Introduction to linked list

Associative Container

Introduction to associative container

String Manipulation

Learning Resources

For learning more, you may check out following online resources:

Contributing

All contributions are welcome, including typo fix! Please read the contrubuting guideline first before starting your work.

Contributors

License

This project is released under different licenses based on type of the content.

Copyright © 2017 - 2021 Weihang Lo

Comments
  • Associate Container/Set

    Associate Container/Set

    Will close part of #4

    The code implementation (set/mod.rs) will be push/rebase in thie branch. Besides the code, the draft will be edit in HackMD before ready to publish. Please feel free to add/suggest good topics to cover! 👉https://hackmd.io/VsM13vR1TrKzVRsKpHuTjA?both

    opened by choznerol 4
  • 🚧Impletement Associative Container Skip List

    🚧Impletement Associative Container Skip List

    I want to accomplish the "Skip list" for searching. Used in leveldb. However, I could only make it with unsafe Rust and not sure there are no memory leak.

    • [x] Skip list.
    opened by LebranceBW 2
  • Make get/get_mut/remove in HashMap more flexible with Borrow trait

    Make get/get_mut/remove in HashMap more flexible with Borrow trait

    I noticed the TODO message along with the helpful hints in the HashMap implementation:

    https://github.com/weihanglo/rust-algorithm-club/blob/188bb59ee0808dd0da4632eccf3b1cce192ed2be/src/collections/hash_map/mod.rs#L61-L86

    if it's not currently under development, I would love to give it a try!

    opened by choznerol 2
  • cargo checked failed for singly linked list

    cargo checked failed for singly linked list

    OS: macOS 10.14.1 rustc version: 1.28.0

        Checking rust-algorithm-club v0.0.1 (file:///Users/henry/Develop/rust-algorithm-club)
    error[E0309]: the parameter type `T` may not live long enough
      --> src/collections/singly_linked_list/mod.rs:31:5
       |
    30 | pub struct Iter<'a, T> {
       |                     - help: consider adding an explicit lifetime bound `T: 'a`...
    31 |     next: Option<&'a Node<T>>,
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^
       |
    note: ...so that the reference type `&'a collections::singly_linked_list::Node<T>` does not outlive the data it points at
      --> src/collections/singly_linked_list/mod.rs:31:5
       |
    31 |     next: Option<&'a Node<T>>,
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    
    error[E0309]: the parameter type `T` may not live long enough
      --> src/collections/singly_linked_list/mod.rs:38:5
       |
    37 | pub struct IterMut<'a, T> {
       |                        - help: consider adding an explicit lifetime bound `T: 'a`...
    38 |     next: Option<&'a mut Node<T>>,
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
    note: ...so that the reference type `&'a mut collections::singly_linked_list::Node<T>` does not outlive the data it points at
      --> src/collections/singly_linked_list/mod.rs:38:5
       |
    38 |     next: Option<&'a mut Node<T>>,
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    error[E0309]: the parameter type `T` may not live long enough
       --> src/collections/singly_linked_list/mod.rs:229:5
        |
    228 | impl<'a, T> Iterator for Iter<'a, T> {
        |          - help: consider adding an explicit lifetime bound `T: 'a`...
    229 |     type Item = &'a T;
        |     ^^^^^^^^^^^^^^^^^^
        |
    note: ...so that the reference type `&'a T` does not outlive the data it points at
       --> src/collections/singly_linked_list/mod.rs:229:5
        |
    229 |     type Item = &'a T;
        |     ^^^^^^^^^^^^^^^^^^
    
    error[E0309]: the parameter type `T` may not live long enough
       --> src/collections/singly_linked_list/mod.rs:242:5
        |
    241 | impl<'a, T> Iterator for IterMut<'a, T> {
        |          - help: consider adding an explicit lifetime bound `T: 'a`...
    242 |     type Item = &'a mut T;
        |     ^^^^^^^^^^^^^^^^^^^^^^
        |
    note: ...so that the reference type `&'a mut T` does not outlive the data it points at
       --> src/collections/singly_linked_list/mod.rs:242:5
        |
    242 |     type Item = &'a mut T;
        |     ^^^^^^^^^^^^^^^^^^^^^^
    
    error: aborting due to 4 previous errors
    
    For more information about this error, try `rustc --explain E0309`.
    error: Could not compile `rust-algorithm-club`.
    
    To learn more, run the command again with --verbose.
    
    opened by henry40408 1
  • cargo check failed

    cargo check failed

    error message

    error: failed to parse manifest at `/Users/henry/Develop/rust-algorithm-club/Cargo.toml`
    
    Caused by:
      editions are unstable
    
    Caused by:
      feature `edition` is required
    
    this Cargo does not support nightly features, but if you
    switch to nightly channel you can add
    `cargo-features = ["edition"]` to enable this feature
    
    opened by henry40408 1
  • Basic stack and queue ADT implementation

    Basic stack and queue ADT implementation

    Here are some abstract data type need documentations and implementations.

    Feel free to pick the one you like and leave comments below. Hands on coding!

    help wanted 
    opened by weihanglo 1
  • Binary search variants

    Binary search variants

    Here are some variants of binary search algorithm that needs well-documented implementations and tutorials.

    Feel free to pick the one you like and leave comments below. Hands on coding!

    help wanted 
    opened by weihanglo 1
  • Use stable Rust when 2018 edition is available

    Use stable Rust when 2018 edition is available

    Currently we depend on nightly compiler to pass all CI process and deploy automatically. (Related issue https://github.com/weihanglo/rust-algorithm-club/commit/bab20832e55f2e040f9c7ed45141475c4bc1b2d6)

    Plan to switch back to stable Rust when 2018 edition is available on stable channel.

    opened by weihanglo 1
  • The scope of the unsafe block can be appropriately reduced

    The scope of the unsafe block can be appropriately reduced

    In this function you use the unsafe keyword for some safe expressions.

    We need to mark unsafe operations more precisely using unsafe keyword. Keeping unsafe blocks small can bring many benefits. For example, when mistakes happen, we can locate any errors related to memory safety within an unsafe block. This is the balance between Safe and Unsafe Rust. The separation is designed to make using Safe Rust as ergonomic as possible, but requires extra effort and care when writing Unsafe Rust.

    Hope this PR can help you. Best regards. References https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html

    opened by cactter 1
  • Implement

    Implement "Linear Median Finding"

    I am going to implement this one. Which category do you want it to belong with?

    Reference: https://rcoh.me/posts/linear-time-median-finding/ https://en.wikipedia.org/wiki/Median_of_medians

    opened by tigercosmos 1
  • Fill the emptiness of generated doc

    Fill the emptiness of generated doc

    The generated Rust doc is public now. Yet it seems too dumb and lack some descriptions. The crate and each modules need to be documented.

    For crate doc itself, suppose we can reuse the English version of the root README.md file. Concerning module level docs, the Chinese articles are also absent. We should write down both English and Chinese intros for these three modules.

    Any thought Rustaceans?

    Missing Docs

    • [ ] crate itself
    • [ ] searching module
    • [ ] collections module
    • [ ] sorting module
    enhancement 
    opened by weihanglo 0
  • Linked list implementations

    Linked list implementations

    opened by weihanglo 1
  • Associative container variants

    Associative container variants

    Here are some associative container variants that needs well-documented implementations and tutorials.

    Feel free to pick the one you like and leave comments below. Hands on coding!

    help wanted 
    opened by weihanglo 5
  • Efficient sorting algorithms

    Efficient sorting algorithms

    Here are some efficient sorting algorithms that needs well-documented implementations and tutorials.

    Feel free to pick the one you like and leave comments below. Hands on coding!

    help wanted 
    opened by weihanglo 0
Owner
Weihang Lo
Life is a refactoring process without tests. 🦀 Always open to Rust job opportunities.
Weihang Lo
Algorithms and Data Structures of all kinds written in Rust.

Classic Algorithms in Rust This repo contains the implementation of various classic algorithms for educational purposes in Rust. Right now, it is in i

Alexander González 49 Dec 14, 2022
Common data structures and algorithms in Rust

Contest Algorithms in Rust A collection of classic data structures and algorithms, emphasizing usability, beauty and clarity over full generality. As

Aram Ebtekar 3.3k Dec 27, 2022
rust_aads - Rust Algorithms And Data Structures

rust_aads - Rust Algorithms And Data Structures rust_aads is an open repository with algorithms and data structures, used in computer science and comp

stepa 2 Dec 15, 2022
Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.

null 6.5k Dec 31, 2022
Rust data structures and client for the PubChem REST API

pubchem.rs Rust data structures and client for the PubChem REST API. ?? Usage ?? Compound Create a Compound to query the PubChem API for a single comp

Martin Larralde 2 Jan 18, 2022
Obake is a procedural macro for declaring and maintaining versioned data-structures.

Obake is a procedural macro for declaring and maintaining versioned data-structures. The name 'obake' is taken from the Japanese 'お化け (おばけ)', a class of supernatural beings in Japanese folklore that shapeshift.

Nathan Corbyn 174 Dec 26, 2022
Fast, efficient, and robust memory reclamation for concurrent data structures

Seize Fast, efficient, and robust memory reclamation for concurrent data structures. Introduction Concurrent data structures are faced with the proble

Ibraheem Ahmed 240 Dec 23, 2022
Rust Persistent Data Structures

Rust Persistent Data Structures Rust Persistent Data Structures provides fully persistent data structures with structural sharing. Setup To use rpds a

Diogo Sousa 883 Dec 31, 2022
A proof of concept implementation of cyclic data structures in stable, safe, Rust.

A proof of concept implementation of cyclic data structures in stable, safe, Rust. This demonstrates the combined power of the static-rc crate and the

null 157 Dec 28, 2022
Rust library for string parsing of basic data structures.

afmt Simple rust library for parsing basic data structures from strings. Usage You can specify string formats to any strucute, via the use of the fmt

Eduard 4 May 8, 2021
Library containing various Data Structures implemented using Rust.

rust-data-structures Library containing various Data Structures implemented using Rust. Running You can test the library by running cargo test, an exa

c1m50c 1 Jan 6, 2022
A library for comparing data structures in Rust, oriented toward testing

Delta: Structural differencing in Rust The delta crate defines the trait Delta, along with a derive macro for auto-generating instances of this trait

John Wiegley 19 Oct 7, 2022
A library for comparing data structures in Rust, oriented toward testing

The comparable crate defines the trait [Comparable], along with a derive macro for auto-generating instances of this trait for most data types. Primar

John Wiegley 19 Oct 7, 2022
Collection of Data Structures in Rust

cds - Collection of Data Structures !!! UNDER CONSTRUCTION !!! The version v0.0.1 is a crates.io placeholder. License Licensed under either of Apache

Rafael Buchbinder 2 May 23, 2022
Succinct data structures in Rust

sucds: Succinct data structures in Rust sucds contains some succinct data structures written in Rust. Data structures So far, the following data struc

Shunsuke Kanda 43 Dec 3, 2022
Dade is data definition for Rust structures.

dade dade is data definition for Rust structures. For the easy handle of data, the following will support it. Data validation. Data schema conforms Js

odd 3 May 1, 2022
NixEl is a Rust library that turns Nix code into a variety of correct, typed, memory-safe data-structures

?? NixEL Lexer, Parser, Abstract Syntax Tree and Concrete Syntax Tree for the Nix Expressions Language. NixEl is a Rust library that turns Nix code in

Kevin Amado 56 Dec 29, 2022
This repository aims to organize codes related to data structures in Rust. 🦀

Rust Data Structure A project with the objective of introducing the main concepts about data structure using Rust! Explore the docs and learn Rust » R

guto 12 Apr 3, 2023
Garbage Collector(Hyaline- Safe Memory Reclaimation) for lock free data structures

Hyaline-SMR This crate provides garbage collection using hyaline algorithm for building concurrent data structures. When a thread removes an object fr

Abishek 2 Dec 21, 2022