ProAlgos / ProAlgos-Cpp

C++ implementations of well-known (and some rare) algorithms, while following good software development practices
MIT License
507 stars 363 forks source link

Fenwick Trees #388

Closed PhysicsUofRAUI closed 3 years ago

PhysicsUofRAUI commented 3 years ago

Hello. I want to add the Fenwick Trees to your list of data structures.

alxmjo commented 3 years ago

Sorry it took me a couple days to get back to you. Please go ahead and let me know if you have any questions.

PhysicsUofRAUI commented 3 years ago

Hey! I was wondering if it should be in the trees folder? Conceptually Fenwick Trees are trees but when implemented they are just a flat array. Currently I plan to add it to the trees folder.

alxmjo commented 3 years ago

I agree – filing under trees makes more sense.

PhysicsUofRAUI commented 3 years ago

I want to add an example explaining how the two's complement and the AND operator work in this part of the code index += (index & -index) . I think it is a confusing part of the code. Should I add it in the comments or create a documentation file, like found in the algorithms, and add it there?

alxmjo commented 3 years ago

Add it in the comments. I don't think I'd ever check a documentation file for that kind of clarification.

PhysicsUofRAUI commented 3 years ago

OK. I was also wondering when I make the documentation file should I leave out the binary search tree documentation. I would be willing to do it later, but it might be better to have it in a separate commit.

alxmjo commented 3 years ago

It's up to you. If you don't add now we'd certainly appreciate the addition later.

PhysicsUofRAUI commented 3 years ago

I made a pull request with just the fenwick tree documentation and implementation. Next I can add the binary search tree documentation.