Question: (Medium-Hard) What is the big-Oh runtime for the following segment of code? int n, i; scanf(%d, &n); for (i = 0; i < n; i++)
(Medium-Hard) What is the big-Oh runtime for the following segment of code? int n, i; scanf("%d", &n); for (i = 0; i < n; i++) { int tn = i + 1; while (0 == (tn & 1)) { sum++; tn /= 2; // or tn >>= 1; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
