Points-in-rectangle count
Sweep x. At start-x of query rectangle: subtract cumulative BIT. At end-x: add. At point events: update BIT[y] += 1.
Advertisement
Offline vs online
Offline: sort all events, sweep. Online: 2D persistent segment tree, O(log² N).
Advertisement
Complexity
Offline: O((N + Q) log N). Online with persistence: O(N log N) build + O(log² N) query.
Applications
Spatial databases. Analytics queries ('customers in region during time'). GIS.