Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anupam-io/avl_tree
AVL tree: height-balanced trees in C supporting add, remove, search, update features. A comparison of AVL trees with red-black trees is also done(std::set).
https://github.com/anupam-io/avl_tree
avl-tree avl-tree-code avl-tree-implementations bst c data-structures height-balanced-trees red-black-trees rotations std
Last synced: about 2 months ago
JSON representation
AVL tree: height-balanced trees in C supporting add, remove, search, update features. A comparison of AVL trees with red-black trees is also done(std::set).
- Host: GitHub
- URL: https://github.com/anupam-io/avl_tree
- Owner: anupam-io
- Created: 2019-10-08T10:20:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-12T15:40:11.000Z (about 4 years ago)
- Last Synced: 2024-10-28T17:27:26.704Z (3 months ago)
- Topics: avl-tree, avl-tree-code, avl-tree-implementations, bst, c, data-structures, height-balanced-trees, red-black-trees, rotations, std
- Language: C
- Homepage:
- Size: 127 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AVL Trees: perfectly balanced, as all things should be
## Introduction
[AVL trees](https://en.wikipedia.org/wiki/AVL_tree)(named after inventors Adelson-Velsky and Landis), also known as height-balanced trees are a widely-used data structure when it comes to efficient read, write and search operations.Similar to a [BST(binary search tree)](https://en.wikipedia.org/wiki/Binary_search_tree), an AVL tree also has basic operations:
- add()
- remove()
- search()But what makes an AVL tree efficient and fast
- always height balanced
- balance factor on any node is 0 or 1
- always achieves minimum height
- by [rotations](https://en.wikipedia.org/wiki/Tree_rotation)## How is it perfect balanced
At the time of insertions and deletions:
- it finds the first node where one side becomes more heavy than the other
- fix this by RR, RL, LR, LL rotations
- the whole tree is balanced## Comparision with RB trees
I have compared my implementation with the [std::set](http://www.cplusplus.com/reference/set/set/)(implemented with [red-black trees](https://en.wikipedia.org/wiki/Red%E2%80%93black_tree)) for different workloads.
Here are the results:## How to use ?
- defining an instance of avl tree:
- `tree* my_tree = new_tree();`
- adding an element:
- `add_t(my_tree, 77);`
- removing an element:
- `remove_t(my_tree, 67);`
- searching for an element:
- `find_t(my_tree, 57);`
- deleting the instance of tree:
- `delete_tree(my_tree);`
## Contributors