for(i=n/2;i<=n;i++) {
for(j=1;j<= n/2;j++) {
for(k=1;k<=n;k=k*2) {
statement;
}
}
}
what is the complexity for that code i think it would be in log with n^2 but i can't find it please answer me.
for(i=n/2;i<=n;i++) {
for(j=1;j<= n/2;j++) {
for(k=1;k<=n;k=k*2) {
statement;
}
}
}
what is the complexity for that code i think it would be in log with n^2 but i can't find it please answer me.
for(i=n/2;i<=n;i++) { // it is O(n)
for(j=1;j<= n/2;j++) { // it is O(n)
for(k=1;k<=n;k=k*2) { // it is O(log n)
statement;
}
}
}
so O(n^2 * (log n))