How to find complexity of this loop
Program 1:
for(i=1;i<=n;i++)
{
for(j=n/3;j<=2n;j+=n/3)
{
x=x+1;
}
}
I've solved question like this
Program 2:
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
x=x+1;
}
}
here time complexity of above code will be $O(n^2)$ But how to find time complexity of programs like Program 1
Aucun commentaire:
Enregistrer un commentaire