How exactly is the square root decomposition of queries (also sometimes referred to as Mo's Algorithm), used for offline processing of queries? If possible, please explain with an example.
NOTE :- I've gone over this post, but it lacks in covering the topic with an example and complexity analysis properly.
I think it might be easier to understand if I explain with an actual solution of a problem. The problem is this one and the solution is as follows.
SQRT-decomposition is a concept that's very hard to understand, at least for me. I hope I was clear enough.
This is also a very good tutorial on Mo's algorithm.
http://blog.anudeep2011.com/mos-algorithm/