Skip to content

Commit 2454dfa

Browse files
rytheogithub-actionssiriak
authored
Add AVL Tree (rust-lang#186)
* feat(data_structures): add AVL tree * feat(avl_tree): add is_empty and default methods * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Andrii Siriak <[email protected]>
1 parent eb4bf63 commit 2454dfa

File tree

5 files changed

+400
-1
lines changed

5 files changed

+400
-1
lines changed

DIRECTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [Rot13](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/rot13.rs)
88
* [Vigenere](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/vigenere.rs)
99
* Data Structures
10+
* [Avl Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/avl_tree.rs)
1011
* [B Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/b_tree.rs)
1112
* [Binary Search Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/binary_search_tree.rs)
1213
* [Graph](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/graph.rs)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ These are for demonstration purposes only.
5050
- [ ] Trie
5151
- [x] [Binary Search Tree](./src/data_structures/binary_search_tree.rs)
5252
- [x] [B-Tree](./src/data_structures/b_tree.rs)
53-
- [ ] AVL Tree
53+
- [x] [AVL Tree](./src/data_structures/avl_tree.rs)
5454

5555
## [Strings](./src/string)
5656

src/data_structures/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ __Sources to read:__
1818
* [Rust API Docs](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html)
1919
* [Keon Algorithms](https://github.com/keon/algorithms)
2020
* [MIT Open Course](https://www.youtube.com/watch?v=TOb1tuEZ2X4)
21+
22+
### [AVL Tree](./avl_tree.rs)
23+
24+
An AVL Tree is a self-balancing binary search tree. The heights of any two sibling
25+
nodes must differ by at most one; the tree may rebalance itself after insertion or
26+
deletion to uphold this property.
27+
28+
__Properties__
29+
* Worst/Average time complexity for basic operations: O(log n)
30+
* Worst/Average space complexity: O(n)
31+
32+
__Sources to read:__
33+
* [Wikipedia](https://en.wikipedia.org/wiki/AVL_tree)
34+
* Geeksforgeeks
35+
([Insertion](https://www.geeksforgeeks.org/avl-tree-set-1-insertion),
36+
[Deletion](https://www.geeksforgeeks.org/avl-tree-set-2-deletion))

0 commit comments

Comments
 (0)