🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Segment Tree and Fenwick Tree: all 10 questions

Quiz: Segment Tree and Fenwick Tree · Question 9 of 10

Why must a Fenwick tree use 1-based indexes?

Why must a Fenwick tree use 1-based indexes?

  1. A.Java arrays start at 1
  2. B.It saves memory
  3. C.At index 0, i & −i is 0, so the update loop would never move
  4. D.Index 0 always stores the total sum
Answer & explanation

Correct answer: At index 0, i & −i is 0, so the update loop would never move

The jumps depend on the lowest set bit, and 0 has no set bit.

Can you get the rest right without peeking?

Take the timed Quiz: Segment Tree and Fenwick Tree quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →