atlas-rb-tree

Crates.ioatlas-rb-tree
lib.rsatlas-rb-tree
version0.1.0
sourcesrc
created_at2024-04-04 17:16:42.569288
updated_at2024-04-04 17:16:42.569288
descriptionA textbook implementation of a Red-Black Tree.
homepage
repositoryhttps://github.com/DanielThurau/atlas-rb-tree
max_upload_size
id1196522
size37,640
Daniel Thurau (DanielThurau)

documentation

README

Red-black Tree in Rust

This project is a Rust implementation of the Red-black Tree data structure as described in Introduction to Algorithms 4th edition. You could call this a "textbook implementation".

A Red-black Tree is a kind of self-balancing binary search tree. Each node of the tree has an extra bit for denoting the color of the node, either red or black. A Red-black Tree ensures a balanced tree by enforcing certain rules through rotations and color changes of nodes, which in turn guarantees O(log n) time complexity for search, insertion, and deletion operations.

Usage

Here's a quick example of how to use the Red-black Tree to insert elements and search within the tree:

use atlas_rb_tree::Tree;

fn main() {
    let mut tree = Tree::new(0); 
    tree.insert(5);
    tree.insert(3);
    tree.insert(10);
    if tree.contains_key(5) {
        println!("Found 5 in the tree!");
    }
    
    tree.delete(5);
}

Running the tests

cargo test

Running the benchmarks

cargo bench

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Commit count: 21

cargo fmt