retagged by
422 views
0 votes
0 votes
What is the total no of multiplications to be performed??

D=2

For i=1 to n do

    For j=i+1 to n do

       For k=j+1 to n do

          D=D×3
retagged by

1 Answer

1 votes
1 votes

for(i=1 to n)

  for(j=i+1 to n)

    for(k=j+1 to n)

For n=0; mult=0;

for n=1;mult=0;

for n=2; mult=0;

for n=3;mult=1;   for n=4;mult=4     and n=5 mult=10;[putting n checked no of iteration satisfied for multiplication;

For gen it must contain n,(n-1),(n-2) as factor so by so checked for general formula for n terms.

no of multiplication =[n*(n-1)*(n-2)/6]

   

Related questions

2 votes
2 votes
3 answers
3
Jyoti Kumari97 asked May 25, 2019
6,008 views
Question:$T(1)=1$$T(n) = 2 T(n - 1) + n$evaluates to?Can anyone solve it by substitution method?Given answer $T(n) = 2^{n+1} - (n+2)$How?
1 votes
1 votes
1 answer
4
Sambhrant Maurya asked Aug 2, 2018
569 views
for(i=n,j=1;i>=1;i=i/2,j=j+i)What is the value of j by the end of the loop?a) O(log n) b)O(n) c) O(n2) d)O(n log n) How do I calculate this?