According to my analysis, the running time of this algorithm should be N2, because each of the loops goes once through all the elements. I am not sure whether the presence of the if statement changes the time complexity?
for(int i=0; i<N; i++){
for(int j=1; j<N; j++){
System.out.println("Yayyyy");
if(i<=j){
System.out.println("Yayyy not");
}
}
}
Total running time will be Tc + N x (To + NxTi + N/2xTp).
This is equal to Tc + NxTo + (Nx(N/2)) x (2Ti + Tp) which is bounded by K x (N^2) for values of K > Ti + Tp/2 as N goes to infinity. This boundary makes the time complexity still O(N^2).
No, the if statement does not change the time complexity in this example.