Why it matters

Offline processing often gives asymptotic gains. Important optimization technique.

Advertisement

The architecture

Sort queries in beneficial order.

Process in batches.

Offline query techniqueCollect queriesall upfrontSort by criterionfor efficient processingProcess batchesamortized costMo's algorithm is classic offline technique
Offline query processing.
Advertisement

How it works end to end

Mo's algorithm: sort by (block of L, R).

Sweeping techniques.

Segment tree + sorted queries.