What I've understood about time complexity is that it measures the no. of operations performed with respect to input. For example
code{
for(int i=0;i<n;i++){ // n opertions
print(array[i]);
}
for(int i=0;i<n;i++{ // n operations
print(array[i}
}
}
If each loop performs n operations then the total no. of operations performed will be 2n Right? Why not include that in the Time Complexity? I mean why is 2 neglected in O(n) instead of O(2n)
If n=5 then the first for loop will perform 5 operation and second will perform 5 , So totally it'll perform 10 operations. If n=10 then first loop will perform 10 and second loop will perform 10 operations , So totally the it'll perform 20 operations which is 2n. The above no. of operations will not change no matter how slow your computer performs the no.of operations performed will be 2n. Then my question is why O(n) instead of O(2n).