in Algorithms
485 views
2 votes
2 votes

What is the correct time complexity in $\theta()$ ?

in Algorithms
by
485 views

4 Comments

@h4kr Continuing @Kabir5454 ‘s equation:-

$\sum_{i=1}^{n}\sum_{j=1}^{i}\sum_{k=1}^{j} c$ 

$=\sum_{i=1}^{n}\sum_{j=1}^{i}(j)$

$=\sum_{i=1}^{n}(i(i+1)/2)$

$=\sum_{i=1}^{n}(i^2+i)/2)$

$=(1/2)\sum_{i=1}^{n}(i^2+i)$

$=(1/2)\{[(n(n+1)(2n+1)/6] + [(n(n+1)/2)]\}$

$=\Theta(n^3)$

2
2
Correct
1
1
solving  by matrix entry

1…………………….

1    2……………………

1    2    3………………..

……….

1    2   3………………….………………n-2

sum of the all entry of  n-2 *n-2 matrix =(n-2)*(n-1)(n-2)/2  

here half of the entry fill  hence devide by 2   

means it is asymptotically eqaul to theta(n^3)
0
0

1 Answer

2 votes
2 votes
Best answer

Answer: $\Theta(n^3)$

The Loop Equation can be written as:-

$\sum_{i=1}^{n}\sum_{j=1}^{i}\sum_{k=1}^{j} c$ 

$=\sum_{i=1}^{n}\sum_{j=1}^{i}(j)$

$=\sum_{i=1}^{n}(i(i+1)/2)$

$=\sum_{i=1}^{n}(i^2+i)/2)$

$=(1/2)\sum_{i=1}^{n}(i^2+i)$

$=(1/2)\{[(n(n+1)(2n+1)/6] + [(n(n+1)/2)]\}$

$=\Theta(n^3)$

selected by

Related questions