⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 25s17 days 22 hours 20 minutes 25 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 25s17 days 22 hours 20 minutes 25 seconds.

Sign in to watch this lesson
Algorithms - Trees and Range Queries · 5:39
A segment tree gives every half of every half of an array its own vertex, so any range is answered by a handful of stored results. We build one on a small array, run a range-sum query through its three cases, update one element, prove that a query visits at most four vertices per level, store the tree in a 4n array or the compact bottom-up layout, and measure it against a plain loop and a Fenwick tree.