-
Notifications
You must be signed in to change notification settings - Fork 313
Added ArraySegmentTree
and RangeQueryDynamic
#483
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
I would name it as |
Thank you for your feedback..I will make these changes..as soon as possible to make it more readable and clean... |
Hello @czgdp1807, I have added all necessary DocStrings with examples and test cases for using the data structure...And have also placed it in the right folder [miscellaneous data structures] as you mentioned.. I request you to review my updated code which I have committed.. |
Overall, you have worked hard on it. Though, have you included n-dimensional segment trees? I think that would make this feature applicable to a lot more use cases. |
Thank you so much for your respect...I haven't added n-dimensional tree yet..and I actually request you to give me little time for that..but would be obliged..if you could merge my project after I add the test cases and also make the changes as you mentioned above and then after that I will add that feature as well and will update it from time to time...Thank You..Will commit the changes as you said above.. |
Please review the changes...will add the changes to test files as well.. |
The code looks really good. Can you make changes to the tests as well in a similar manner (as we discussed on our call)? @Smit-create Can you please check the implementation for correctness? Any API suggestions from your experience? |
Added the updated tests..as well...please review it. |
Now, we need to add Lazy propagation can be added afterwards by adding a new class, something like, |
Could you explain me in detail, of all the changes you did above..as it was quite a lot.. |
Have gone through the commits..but I needed your words.. |
I decoupled the interface and the implementation of segment trees. Basically, segment trees with range updates need to track some extra information and require extra memory, so it would be better to add them separately in a follow up PR. Storing segment trees in arrays would require 4*N sized array which is too much provided the number of nodes are always constant in a segment tree. |
My segment tree takes 2N memory...not 4N typical implementation...anyway..I guess you wanted to completely reorganise the interface..so I will make the commits and changes respectively.. |
Also, what about the previous implementation, which I initially made..so now that's not required anymore (other than reference) ? |
Yes, not required anymore. |
So now I have to do this right? |
You can if you want to. |
ArraySegmentTree
and RangeQueryDynamic
In a follow up PR add, both the new APIs to docs. |
Hey Thanks...alot..meanwhile I am working on order statistic and interval trees also..Will commit them under their PRs.. |
Could you please provide a reference for this? |
It's basically a self balancing tree like RB, AVL, B, van-embde-boas, etc...In the augmented form..where we stored two bits of extra information...for fetching osrank and osselect operations...please refer my C++ implementation for the same under "My Templates repo"...and here is a link for more info: (CLRS pdf) See the augmenting data structures part...before which red black trees is also given... |
Can you check if |
Yes it matches...but you have used AVL trees in your implementation? |
No. Any tree class can call |
So I think that I will start doing interval trees?...Since the repo already contains order statistic..And also this would be kinda nice...to have both kinds of trees...generally speaking RB Trees are most general and efficient also used in C++, Java..and their implementations of their DS.. |
Cool...So I will get back to you directly under that issue.. |
Added Segment Trees with Lazy Propagation :
Functions : RangeQuery, RangeUpdate, PointUpdate...(O(log(n)) time..
Will be further adding more additions for better user experience...