Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 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.