what is order of complexity in Big O notation?

前端 未结 6 1263
挽巷
挽巷 2021-01-01 07:41

Question

Hi I am trying to understand what order of complexity in terms of Big O notation is. I have read many articles and am yet to find anything

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-01 08:11

    Be careful here, there are some subtleties. You stated "we are measuring the time and space complexity of an algorithm in terms of the growth of input size n," and that's how people often treat it, but it's not actually correct. Rather, with O(g(n)) we are determining that g(n), scaled suitably, is an upper bound for the time and space complexity of an algorithm for all input of size n bigger than some particular n'. Similarly, with Omega(h(n)) we are determining that h(n), scaled suitably, is a lower bound for the time and space complexity of an algorithm for all input of size n bigger than some particular n'. Finally, if both the lower and upper bound are the same complexity g(n), the complexity is Theta(g(n)). In other words, Theta represents the degree of complexity of the algorithm while big-O and big-Omega bound it above and below.

提交回复
热议问题