C, Time complexity of sigma?
问题 How may I find the time complexity of the following code: (Sorry for adding image, I will re-edit my question once I have access to the laptop) What I have done so far: The first loop iterates n times, the second i times and the third log(i*j) times, So after simplifying I got: Sigma from i=0 to n for i*log i + n * (Sigma from j=0 to i for log i) But why this is equal to O(n^2 log(n))? 回答1: If we look at the outermost 2 loops we observe that there are 1 + 2 + 3 ... + n - 1 iterations. Using