Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 41s1 days 16 hours 1 minutes 41 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 41s1 days 16 hours 1 minutes 41 seconds.

Sign in to watch this lesson
Algorithms - Trees and Range Queries · 4:07
Prefix sums answer any range sum with one subtraction, but a single changed value forces the whole tail of the prefix array to be rewritten; a plain array is the mirror image. We place both on a plot of update cost against query cost, cut the array into blocks of about root n to bring the worse side down, and time all three on a Mac: each corner wins its own extreme, while the blocks win a realistic mix by more than ten times, setting up the logarithmic structures that come next.