Binary Tree Insertion Algorithm (in Rust)

preview_player
Показать описание
In this video we implement the Binary Search Tree Insertion algorithm(both the iterative and recursive solution) in Rust. We use the recursive data structure for the tree, use Box pointers, Options, and create helper functions to convert between values seamless with the From/Into traits. We cover ownership and mutability, issues with lifetimes and the borrow checker as well. Finally, we also make use of new match expression patterns and the dereference operator when assigning to mutable values.

**NOTES**
As an addition to this exercise, you can implement the Drop trait that you may have come across in previous videos. This video is part of a series where I will be implementing search, insertion, and traversal algorithms in separate videos.

↠ References:

Cheers! 🍻

🦀 #rust #rustlang #rustprogramming #exercises #leetcode #programming
Рекомендации по теме
Комментарии
Автор

Oh man, I've been battling with Rust implementing a BST the last 2 days and it's funny how every single error you mentioned I went through, and I saw the same exact thought process take place. Very funny experience for me haha

banrx
Автор

Thanks, hoping u continue such videos.

ostadomid
Автор

Thank you so much for making these videos! They are very helpful. I used to struggle without knowing about the right idioms in rust and my tree and graph traversals looked very noisy.

Could you also consider making a video on traversals of general graph nodes? I’m curious to know what other idioms exist when there are several wrappers around the payload like Option<Rc<RefCell<Node>>>.

vishnuc
Автор

Great video! May I ask what your theme is?

NeotenicApe
Автор

println!("{:?}", tree);
| ^^^^ `binary_tree::Tree` cannot be formatted using `{:?}`

How did you do a debug printing of tree exactly?

Urthor
join shbcf.ru