Big O for 3 nested loops
Another Big O notation question...What is the Big O for the folling code: for (int i = n; i > 0; i = i / 2){ for (int j = 0; j < n; j++){ for (int k = 0; k < n; k++){ count++; } } } My Thoughts: So breaking it down, I think the outside loop is O(log2(n)) , then each of the inner loops is O(n) which would result in O(n^2 * log2(n)) Question #1 is that correct? Question #2: when combining nested loops is it always just as simple as mulitply the Big O of each loop? When loop counters do not depend on one another, it's always possible to work from the inside outward. The innermost loop always