What is the Big-Oh of the following nested loops:
sum=0;
for(i=0;i<n;i++)
for(j=0;j<i*n;j++)
sum+=i;
and
sum=0;
for(i=0;i<n;i++)
for(j=0;j<i*i;j++)
sum+=i;
I believe it's O(n^2), but all I've ever encountered is both loops using n as the test, so I don't know if O(n^2) is correct. If someone could verify my understanding or explain why I'm wrong, I'd appreciate it. Thanks!