-
Notifications
You must be signed in to change notification settings - Fork 313
[WIP] Added base class SelfBalancingTree for Red Black Tree #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #176 +/- ##
=============================================
+ Coverage 96.735% 96.752% +0.016%
=============================================
Files 23 23
Lines 1746 1755 +9
=============================================
+ Hits 1689 1698 +9
Misses 57 57
|
Looks like a nice idea. Tests are also passing without modifications. The lines not covered in diff were not originally covered so not a concern of this PR. It looks like ready for merging. |
ok so merge this one and I will try to implement RBTree by tomorrow. |
Are the rotation methods in |
in AVLTree its just recalculating the height, which is necessary for balancing in AVL but in case of other trees eg. RedBlackTree we dont actually care about the absolute height. Rotations are not part of how a tree is built or what data its nodes hold, it just moves pointers that is why I dont think it will break the code. |
Any way the code is actually cut from the original functions in AVL tree, so even if Splay Tree is extending from AVL tree there shouldn't be any problem. |
Yes, but what if we subclass |
IMO since they arnt doing anything with the height of tree then the code should be same, but I might have to look into SplayTree to be absolutely sure. |
Just looked into it and I think it wont be a problem if we replace AVLTree with SelfBalancingBinaryTree since the rotations are still the same. Reference: |
Currently the tests are not failing and if in future there is bug then we may need to restore the changes. Merging for now. |
I am sorry, there is a major bug in SelfBalancingTree class, I am opening a PR to revert changes. |
…odezonediitj#176)" This reverts commit f75c300.
References to other Issues or PRs or Relevant literature
Please check if the made changes are advisable or should I just extend RedBlackTree from AVLTree.
Brief description of what is fixed or changed
Added SelfBalancingTree which consists rotations.
Other comments