need to calculate big o and use summation to show results fo
need to calculate big o and use summation to show results
Solution
sum=0; // 1 time
for(i=0;i<n;i++) // running time n
for(j=0;j<i*i;j++) // running time n*(n+1)*(2n+1)/6 (series like 1,4,9,16,25,...)
for(k=0;k<j;k++) // running time n(n+1)/2 (series like 1,2,3,4,5,...)
sum++;
So, the summation of all code is:
=> 1+ ((n) * (n(n+1)/2) * (n*(n+1)*(2n+1) / 6))
=>O(1+n6)
=>O(n6)
