retagged by
223 views
0 votes
0 votes
for(i=0;i<=n;i++)

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

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

                      S++;
retagged by

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)

Related questions

0 votes
0 votes
0 answers
1
Naveen Kumar 3 asked Nov 3, 2018
931 views
Suppose, we have an array of n elements. find the time complexity to search two elements x, y such that:-a) x+y < 100b) x+y 1000Also, state the algorithm/approach for th...
3 votes
3 votes
1 answer
2
sumit_kumar asked Jun 25, 2017
3,124 views
what is time comlexity procedure for following recursive equation by substitution method:T(n)= T(n-1)+T(n-2) , if n>=2 =1 , if n=1; =0 , if n=0.
1 votes
1 votes
1 answer
3
Akriti sood asked Jan 23, 2017
1,283 views
What is the time complexity of the following function foo() void foo() { int i, j; for(i = 1; i <= n ; i++) for(j = i; j <= log(i); j++) printf(“gate”); } what is the...
2 votes
2 votes
1 answer
4