TheAlgorithms / Ruby

All algorithms implemented in Ruby
MIT License
1.18k stars 292 forks source link

Adding `AVL Tree` implementation #200

Closed aparibocci closed 1 year ago

aparibocci commented 1 year ago

As per title, this MR aims to add a Ruby implementation of an AVL tree with distinct key nodes. This is a special case of a binary search tree where self-balancing is implemented upon insertion and deletion, allowing to keep the tree balanced.

Due to self-balancing upon key insertion and deletion, the main operations of this data structure (insertion, deletion, membership) run - in worst case - in O(log(n)), where n is the number of nodes in the tree.

Traversal methods (pre-order, in-order, post-order) with custom consumer as argument are also exposed.

aparibocci commented 1 year ago

Hello @StepfenShawn, could I ask you to have a look at this PR, whenever you have a few minutes? Thank you!

StepfenShawn commented 1 year ago

I'm drowning in a computer competition in this week. So I'll review and debug your code in next week.

aparibocci commented 1 year ago

I'm drowning in a computer competition in this week. So I'll review and debug your code in next week.

Amazing! Thank you and best of luck!