Asymptotic running time of loop

62 Views Asked by At
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?

1

There are 1 best solutions below

0
On

Expressing this in summation form:

enter image description here

The summation term is a harmonic series. From the Wikipedia page it can be approximated as:

enter image description here

Where gamma is the Euler-Mascheroni constant (~0.577). Therefore the overall complexity is:

enter image description here