for(int i = 0 ; i < n ; i = i + 2){
}
Yes, The time complexity of the above for loop is also O(n) because it iterates n/2 times.
So the complexity will be O(n/2), in Complexity analysis, we remove the constant. So it will be O(n).
In complexity analysis, we don't calculate the exact time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…