Skip to content

fix: poor implementation of avl tree - #3231

Open
bertrand-awz wants to merge 3 commits into
TheAlgorithms:masterfrom
bertrand-awz:master
Open

bertrand-awz wants to merge 3 commits into
TheAlgorithms:masterfrom
bertrand-awz:master

Conversation

@bertrand-awz

Copy link
Copy Markdown

Description of Change

The previous AVL implementation did not rebalance the tree after deletion and managed nodes through raw pointers. This change replaces it with a reusable C++17 AvlTree<T> class that rebalances after insertion and deletion and caches node heights.

  • Uses std::unique_ptr for automatic memory management.
  • Supports initializer-list construction, copying, moving, searching, and clearing.
  • Provides size, height, and emptiness queries; duplicate values are ignored.
  • Adds terminal visualization with the root above its children and diagonal Unicode arrows, without external dependencies.
  • Moves the implementation into data_structures/avl_tree/ and updates CMake, DIRECTORY.md, documentation, and the usage example.

Resolve issue mentionned in ToDo List of this project. Here is the link: https://thealgorithms.github.io/C-Plus-Plus/d8/dee/avltree_8cpp.html

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant