$n^2$ is a type of [[Spatial Partitioning]] where each object is stored in a single array. Raycasting with this method means the ray will test with *all* objects, same with queries.