-2
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?

Sabin Chacko
  • 713
  • 6
  • 17

1 Answers1

0

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

meowgoesthedog
  • 14,670
  • 4
  • 27
  • 40