Let's say you have a 2D plot such as this one (as a list of points):
Now let's say you split up the plot into equal square areas like so:
Question 1: If you wanted to find the density of each block (the amount of points per area), what computationally efficient techniques in C could be used (efficiency in terms of RAM usage and processing time)?
(Instead of comparing each point one by one to see if it lies in the interval of each square)
Question 2: If a new point was added, what efficient methods could be used to find which block the point resides in, and calculate the new density of the block.
(**Note: I'm not asking for the MOST efficient method as that would be opinion based)