in Algorithms retagged by
231 views
0 votes
0 votes
for(i=0;i<=n;i++)

    for(j=i;j<=n;j++)

           for(k=j;k<=n;k++)

                      S++;
in Algorithms retagged by
231 views

1 comment

can you please re-format question correctly so that i can understand what exactly the question is
0
0

1 Answer

0 votes
0 votes

for i =0 
______________________
j is 0 to N
so for j =0 
and k is 0 to N
No . of Computations will be N
so for j =1
and k is 1 to N
No . of Computations will be N -1

Similarly Total computations are N + N-1 + ........ + 1 = O(N2)
___________________________________________________
for i = 1 
Computations are like (N-1)2
______________________________________________
for i = 0 to N 
Computations are : N2 + (N-1)2 + ............ + 22+12
Overall O(N3)

by

Related questions