Home > Back-end > Of new encountered a small problem
Of new encountered a small problem
Time:10-20
As shown in figure, how to solve the time complexity?
CodePudding user response:
CodePudding user response:
CodePudding user response:
Popular can be understood as the number of cycle, the specific need to read, this topic choose b
CodePudding user response:
B See cycle through the relationship between the number of times and I Cyclic performed n - 1, this is a linear relationship, so it is O (n) Execution times both 100 n and 10000 n, no matter how much behind plus or minus the fixed value, it is O (n)
Calculate complexity, depending on the number and the relationship between n, and only see polynomial highest project, or index, is crucial to the whole expression of the item, ignore other and various coefficients and constants of
Such as 2 ^ n + n ^ 8 only see 2 ^ n, after all, the exponential growth faster than n how much power of the growth, complexity is O (2 ^ n)