🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Segment Tree and Fenwick Tree: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Why are plain prefix sums a poor choice when values change often?
  2. Q2. In a segment tree, what does each node store?
  3. Q3. During a query, what does a node do if its range is completely inside [L..R]?
  4. Q4. What does this print? (code)
  5. Q5. In a segment tree for range minimum, what should a completely outside node return?
  6. Q6. What does this print? (code)
  7. Q7. In a Fenwick tree, which T entries are added to get prefix(7)?
  8. Q8. What does this print? (code)
  9. Q9. Why must a Fenwick tree use 1-based indexes?
  10. Q10. When is a segment tree a better choice than a Fenwick tree?