-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fenwick Tree: Rewrite to focus on 1-based indexing #1346
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
Comments
Lol no one's updated the website in months. Was I right it was I right? No one's gonna make additions. Instead submit a pull request and pray it gets review on the next year |
Hi! It's actually mentioned in the article here. But I generally agree that the code with 0-based Fenwick is pretty ugly + makes our life harder e.g. when we want to treat all segments uniformly but we can't because of the lacks of the value for the zero-length prefix. That being said, feel free to make a pull request, I think overall it would be a welcomed addition. |
#include class FenwickTree { public:
}; int main() {
} |
@UtsavKashyap1710 thanks for the code, but issues section is only for text discussions, actual contribuitions should be done via pull requests. |
Also take a note of #1298, which addresses a similar concern. |
Article: Fenwick Tree
Problem:
Would you support a rewrite of the article to introduce 1-based indexing first? I believe this would simplify the exposition a lot (it did for me). That's also how Fenwick introduces it in his original paper https://web.archive.org/web/20160307203033/http://olds.blogcn.com/wp-content/uploads/67/6754/2009/01/bit.pdf
Apparently the getsum index operation
i -= i & -i
can also be writteni &= i-1
Btw, wikipedia says the BIT was first introduced by Boris Ryabko in 1989, but I can't actually read it (and it doesn't have nice diagrams) https://web.archive.org/web/20190717074430/http://boris.ryabko.net/dan1989.pdf (English https://boris.ryabko.net/[ryabko1992.pdf](https://boris.ryabko.net/ryabko1992.pdf))
The text was updated successfully, but these errors were encountered: