Wednesday, 7 August 2013

complexity for query?

complexity for query?

If we are given a set of ranges S={ (x1,y1) , (x2,y2) ,......(xk,yk) } on
an array of length n.Then I am given queries from set Q={ (l1,r1) ,
......(li,yi) }. Each query (li,ri) means how many ranges from set S fall
between this range (li,ri).
I just want to know whether following things are possible:
1. Pre-computation in O(n) and then queries in O(1)
2 Pre-computation in O(nlogn) and then queries in O(logn)
PS:I don't want the solution just the above two points, I want to come up
with the solution on my own.

No comments:

Post a Comment