ELI5: Explain Like I'm 5

Segment tree

A segment tree is like a ladder with different levels. Each level can hold different numbers. To make it easier to understand, let’s imagine that your segment tree is a ladder with 10 levels and each level holds a number.

At the bottom level, you have numbers that show you the range of numbers you're interested in (like the numbers 1-10). At the next level, you have numbers that tell you the sum of all the numbers in the range (so the sum of 1-10 would be 55). Then at the third level, you have numbers that tell you the sum of the numbers in the even numbers of the range (so the sum of 2, 4, 6, 8, and 10 would be 30). And so on, until you get to the top level of the ladder where you have the number you're most interested in (like the sum of all the odd numbers in the range, which would be 25).

By using the segment tree, you can quickly calculate the numbers that are important to you in the range you are looking at, without having to look through all of the numbers.