The following C code is apparently O (N) (according to my practice exam). However, I'm not sure why this is O (N), and not O (something * something).
void doit(int N) {
while (N) {
for (int j = 0; j < N; j += 1) {
}
N = N / 2;
}
}
Anyone want to give me some idea about this problem?
Thanks in advance!
source
share