Crates.io | atlas-rb-tree |
lib.rs | atlas-rb-tree |
version | 0.1.0 |
source | src |
created_at | 2024-04-04 17:16:42.569288 |
updated_at | 2024-04-04 17:16:42.569288 |
description | A textbook implementation of a Red-Black Tree. |
homepage | |
repository | https://github.com/DanielThurau/atlas-rb-tree |
max_upload_size | |
id | 1196522 |
size | 37,640 |
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.
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);
}
cargo test
cargo bench
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE.txt file for details.