int i, j, k = 0;
for (i = n/2; i <= n; i++) {
for (j = 2; j <= n; j = j * 2) {
k = k + n/2;
}
}
I came across this question and this is what I think. The outer loop will run, N/2 times and the inner loop will run logN times so it should be N/2*logN. But this is not the correct answer. The correct answer is O(NlogN), can anybody tell me what I am missing? Any help would be appreciated.