Time complexity 如何将时间复杂度O(n^2)与O(n&x2B;log(M))进行比较?

Time complexity 如何将时间复杂度O(n^2)与O(n&x2B;log(M))进行比较?,time-complexity,Time Complexity,我的Lua函数: for y=userPosY+radius,userPosY-radius,-1 do for x=userPosX-radius,userPosX+radius,1 do local oneNeighborFound = redis.call('lrange', userPosZone .. x .. y, '0', '0') if next(oneNeighborFound) ~= nil then table.insert(neighbo

我的Lua函数:

for y=userPosY+radius,userPosY-radius,-1 do 
  for x=userPosX-radius,userPosX+radius,1 do
    local oneNeighborFound = redis.call('lrange', userPosZone .. x .. y, '0', '0')
    if next(oneNeighborFound) ~= nil then
      table.insert(neighborsFoundInPosition, userPosZone .. x .. y)
      neighborsFoundInPositionCount = neighborsFoundInPositionCount + 1
    end
  end   
end
这导致了这个公式:(2n+1)^2 正如我正确理解的,这将是O(n^2)的时间复杂度

我如何将其与具有O(N+log(M))的GEORADIUS(Redis)的时间复杂度进行比较

时间复杂度:O(N+log(M)),其中N是由中心和半径分隔的圆形区域的边界框内的元素数,M是索引内的项目数

我的时间复杂度没有M。我不知道索引(M)中有多少项,因为我不需要知道。我的索引经常更改,几乎每次请求都会更改,而且可能很大

什么时候时间复杂度更好