educative.io

Educative

Solution Review: Big O of Nested Loop with Addition - Data Structures for

In this example it says sum += 1 only takes 2 units previously in lesson https://www.educative.io/courses/data-structures-coding-interviews-python/xVVyKOr31Qn it says x += 1 takes 3 units…checking if it might be a mistake or I might not have understood it clearly

Hi @Annie,

In this lesson, Other Common Asymptotic Notations and Why Big O Trumps Them, we added a note at the end of the lesson.

We will simplify the analysis by just counting the number of executions of each line of code, instead of the number of operations. For example, we will say print(sum) will take one primitive operation instead of two.

When we talk in terms of BigO, we do not count the number of operations to simplify analysis.

I hope this helps.

Happy Learning!

Anum Hassan|Developer Advocate
Educative.io