Order Of Growth complicated for loops
问题 For the following code fragment, what is the order of growth in terms of N? int sum = 0; for (int i = 1; i <= N; i = i*2) for (int j = 1; j <= N; j = j*2) for (int k = 1; k <= i; k++) sum++; I have figured that there is lgN term, but I am stuck on evaluating this part : lgN(1 + 4 + 8 + 16 + ....). What will the last term of the sequence be? I need the last term to calculate the sum. 回答1: You have a geometric progression in your outer loops, so there is a closed form for the sum of which you