The Constant Time Rule

What does Mo's algorithm demand of add and remove, and what happens if add is O(log⁡n)O(\log n)?

A

They must be O(1)O(1) for the O(nm)O(n\sqrt{m}) bound, because the query count dominates. An O(log⁡n)O(\log n) add makes the whole run O(nmlog⁡n)O(n\sqrt{m}\log n). Queries may arrive online, one at a time.

B

They must be O(1)O(1) for the O(nm)O(n\sqrt{m}) bound, because pointer moves dominate. An O(log⁡n)O(\log n) add makes the whole run O(nmlog⁡n)O(n\sqrt{m}\log n). All queries must also be known up front.

C

They must be invertible for the O(nm)O(n\sqrt{m}) bound, because pointer moves dominate. An O(log⁡n)O(\log n) add leaves the whole run at O(nm)O(n\sqrt{m}). All queries must also be known up front.

D

They must be O(1)O(1) for the O(nm)O(n\sqrt{m}) bound, because pointer moves dominate. An O(log⁡n)O(\log n) add makes the whole run O(nlog⁡n)O(n \log n). All queries must also be known up front.