Given a set of distinct points in 2D space, and a rectangle (coordinates of all four points, sides parallel with xy axis) how can I quickly find which points are inside the rectangle?
I'm not interested in the basic solution of going through all points and seeing which one is inside the rectangle. What I'm looking for is an algorithm which will give me fast query times per rectangle.
I don't care how much time I spend in the preprocessing step. What I do care is that after I process my data I obtain a useful structure which gives me fast query times per rectangle.
I know for example I can count how many points I have inside a rectangle in O(logN). That works because I do a lot of heavy processing in the beginning and then query the processed data with a new rectangle every time and get a new count in logN time. I'm looking for a similar algorithm for finding the actual points not just their count.