tree_collections

Crates.iotree_collections
lib.rstree_collections
version0.1.8
sourcesrc
created_at2022-09-29 02:29:27.16887
updated_at2022-10-04 22:33:23.335089
descriptionA collection for tree data structures. It provides APIs that allows users to create memory efficient binary search trees, red-black trees and avl trees.
homepage
repository
max_upload_size
id676319
size140,134
Binkai Tan (steventan1011)

documentation

https://docs.rs/tree_collections/latest/tree_collections/

README

Tree_collections

The purpose of this library is to provide APIs that allows users to create memory efficient binary search tree, red-black tree and AVL tree. Besides, by using this library, users can investigate the performance difference between red-black tree and avl tree, which helps them deeply understand the algorithms.

Quick Start

use tree_collections::prelude::*;

fn main() {
    let mut rb_tree = RBTree::new();
    rb_tree.insert(1);
    rb_tree.insert(2);
    rb_tree.insert(3);
    rb_tree.insert(4);
    rb_tree.insert(5);
    rb_tree.delete(3);
    println!("Red-Black Tree:");
    rb_tree.print();
    println!("Number of leaves: {:?}", rb_tree.count_leaves());
    println!("Height of tree: {:?}", rb_tree.height());

    let mut avl_tree = AVLTree::new();
    avl_tree.insert(1);
    avl_tree.insert(2);
    avl_tree.insert(3);
    avl_tree.insert(4);
    avl_tree.insert(5);
    avl_tree.delete(3);
    println!("AVL Tree:");
    avl_tree.print();
    println!("Number of leaves: {:?}", avl_tree.count_leaves());
    println!("Height of tree: {:?}", avl_tree.height());
}

Documentation

Find the API doc at: https://docs.rs/tree_collections/latest/tree_collections/

or build the documentation using

$ cargo doc

User Promote

Run the user promote

$ cargo run

List of operations

$ insert
$ delete
$ count
$ height
$ inorder print
$ preorder print
$ empty
$ search
$ print tree
$ exit

Testing

Run the tests using

$ cargo test

Benchmark

Run the Benchmark using

$ cargo bench

Requirements

Cargo version: 1.56^

Ref: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html

Commit count: 0

cargo fmt