tee_01's blog

By tee_01, history, 4 hours ago, In English

Fenwick Trees are often introduced as a compact implementation trick for prefix sums.

But the interesting part is not the code. The interesting part is the binary structure underneath:

why ranges partition the way they do what i & -i is actually extracting how prefix traversal emerges naturally from binary decomposition why both updates and queries become logarithmic

I made a video trying to build intuition for these ideas visually and structurally rather than treating BIT as something to memorize.

Topics covered:

  • naive approaches and prefix sums
  • lowest set bit (LSB)
  • derivation of i & -i
  • block size interpretation
  • traversal logic
  • implementation walkthrough

Video: YouTube link Would genuinely appreciate feedback from experienced CP users on the content, and from people learning if its easier to understand especially if there are cleaner ways to think about or explain the structure.

References:

  • Vote: I like it
  • +11
  • Vote: I do not like it

»
4 hours ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Don't know whether it's mentioned in the video, but I love the idea that the structure of Fenwick tree is basically the segment tree with every right segment removed.

  • »
    »
    3 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Ahh, i should've used this POV. will write it in the description if you don't mind :P

    • »
      »
      »
      3 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      sure, why not