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

Sign in to watch this lesson
Advanced - Data Structures and Range Queries · 4:44
A merge sort tree stores each node's segment as a sorted list, built bottom-up with std::merge in O(n log n) time and memory, and answers threshold questions such as the smallest value at least x in a range, or how many values fall in a band, with a binary search in each of the O(log n) covering nodes. Fractional cascading stores, for every value, its position in both children, so one search at the root suffices, though on real hardware the extra memory can make it slower. The same nesting gives 2D segment trees (16nm memory) and their compressed form for points.