educative.io

Educative

Why isn't n added when calculating Big O for the examples

In the python interview questions course:
page - https://www.educative.io/module/lesson/algorithms-in-python/YVEgVRMVYnY

There are 2 examples to calculate Big O for :

  1. Nested For-loop with Dependant Variables
  2. Nested For-loop with Index Modification

In both these examples shouldn’t there be an additional ‘n’ added to the overall calculations? i see that only inner loop operations are being considered when calculating Big O

Hi @udai!

We are performing the worst-case analysis in the lessons. As Big O notation corresponds to the growth of f(n) as n gets large, we can ignore the lower-order terms, i.e., n, and we are only interested in higher-order terms, i.e., n^2 in both cases.
​​