math - Time complexity of a function with time 1 + 8 + 27 + 64 + ... + sqrt(n)^3? -


i have been told that

1 + 8 + 27 + 64 + ... + (√n)3 = θ(n2)

why case?

to make sure understand you're saying, curious in why sum

13 + 23 + 33 + ... + (√n)3 = θ(n2)

one way a formula sum of first m cubes. equal to

(m(m + 1) / 2)2

so let's plug in m = √n, gives

13 + 23 + 33 + ... + (√n)3

= ((√n)((√n) + 1) / 2)2

= ((n + √n) / 2)2

= (n2 + 2n√n + n) / 4

this final expression gives exact value of sum of first √n perfect cubes. note expression θ(n2), because n2 dominant term.

hope helps!


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -