function func5(n)
s = 0;
for i = 1 to 3n^2 do
for j = 1 to floor(2n^3/i) do
s=s + i − j;
return(s);
What is the asymptotic running time of the above algorithms in theta notation?
function func5(n)
s = 0;
for i = 1 to 3n^2 do
for j = 1 to floor(2n^3/i) do
s=s + i − j;
return(s);
What is the asymptotic running time of the above algorithms in theta notation?
Expressing this in summation form:
The summation term is a harmonic series. From the Wikipedia page it can be approximated as:
Where
gamma
is the Euler-Mascheroni constant (~0.577). Therefore the overall complexity is: