What is Big O of a loop?

前端 未结 6 834
离开以前
离开以前 2020-12-03 15:02

I was reading about Big O notation. It stated,

The big O of a loop is the number of iterations of the loop into number of statement

6条回答
  •  囚心锁ツ
    2020-12-03 15:44

    Big-O notation ignores constant multipliers by design (and by definition), so being O(n) and being O(2n) is exactly the same thing. We usually write O(n) because that is shorter and more familiar, but O(2n) means the same.

提交回复
热议问题