what is the difference between O(nk) and O(n+k) in time complexity?

后端 未结 5 1144
北荒
北荒 2021-01-01 03:14

In big O notation of time complexity in algorithmic analysis, when an algorithm depends on n and k, what is the difference between these two notations. Also pls help in the

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 04:09

    It should be clear that these are different since, for example if n=k:

    O(nk)=O(nn)=O(n^2)

    O(n+k)=O(2n)=O(n)

提交回复
热议问题