04 Try it yourself Interactive
Two tabs, one array. Build fills the 15 nodes bottom-up so you can see where every stored number comes from — in that tab amber marks the two children currently being added and green marks the nodes already filled. Range query runs the descent: amber means the node straddles the range and has to split, green means it sits entirely inside and its value is taken whole, rose means it is outside and returns nothing. Grey nodes are never visited at all — that is the O(log n).