← 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?
- A.Java arrays start at 1
- B.It saves memory
- C.At index 0, i & −i is 0, so the update loop would never move
- 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 →