Confusion Regarding Time Complexity Of MO's algorithm

Revision en1, by code_warrior, 2020-06-15 05:30:25

I recently read the tutorial on MO's algorithm and found that the time complexity of mo's algorithm is O(q*(n/k)+n*k) where k is the block size and q is the number of queries. But ,how can it be so? For example- If i take q=2 and the ranges to be [1,n] and [n-1,n]. Then ,obviously the left pointer will have to move approx n cells and not q*sqrt(n) which is 2*sqrt(n). Please ,someone clarify my doubt!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English code_warrior 2020-06-15 05:30:25 463 Initial revision (published)