feat(rust/tree): add binary_tree (#398)

*  feat(rust/hashing): add array_hash_map

* 📃 docs(rust/hashing): correct comments

*  feat(rust/include): add tree_node

*  feat(rust/include): add print_tree

*  feat(rust/tree): add binary_tree

* docs(rust/tree): correct comments

* 📃 docs(rust/tree): correct comments
This commit is contained in:
xBLACKICEx
2023-03-07 16:46:28 +01:00
committed by GitHub
parent 13e5fced78
commit 590b532606
5 changed files with 123 additions and 3 deletions
+29
View File
@@ -0,0 +1,29 @@
/**
* File: tree_node.rs
* Created Time: 2023-02-27
* Author: xBLACKICEx (xBLACKICE@outlook.com)
*/
use std::cell::RefCell;
use std::rc::Rc;
#[allow(dead_code)]
pub struct TreeNode {
pub val: i32,
pub high: i32,
pub parent: Option<Rc<RefCell<TreeNode>>>,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
pub fn new(val: i32) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
val,
high: 0,
parent: None,
left: None,
right: None
}))
}
}