Confusion Regarding Time Complexity Of MO's algorithm

Правка en1, от 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!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский code_warrior 2020-06-15 05:30:25 463 Initial revision (published)