Example 1: Measuring Time Complexity



I need help in understanding the part where “sum+=1” was given a complexity of n. I thought it should be 2n as the example in the introduction section explained that sum+=1, involves two operations, one is addition and the other being assignment.

Thanks in advance!