retagged by
400 views

2 Answers

3 votes
3 votes
$T(n) = T(n-2) + n^{^{2}}$

$T(n-2) = T(n-4) + (n-2 )^{^{2}}$

$T(n-4) = T(n-6) + (n-4 )^{^{2}}$

so this goes on till n goes to zero

$n-2x = 0$

$\rightarrow x= \frac{n}{2}$

so finally

$T(n) = 1+n^{^{2}} + (n-2)^{^{2}}+(n-4)^{^{2}}..........$  $\frac{n}{2} times$

Each contain a $n^{2}$ term and they are $\frac{n}{2}$ of those so it will be $O(n^{3})$
1 votes
1 votes

Yes solution is O(n3  solve it by mathematical induction. in end you will get a series of sum of square of first n natural number which will result in O(n^3) 

sumSquaresNatNumbersFormulae.gif

 O(n3)

Related questions

1 votes
1 votes
0 answers
2
syncronizing asked Mar 15, 2019
1,298 views
Is this the correct way to solve ?Q) int algorithm(int n){ int sum =0;k,j; for (k=0;k<n/2;k++) for(j=0;j<10;j++) sum++; return 4*algorithm(n/2)*algorit...
1 votes
1 votes
1 answer
3
VikramRB asked Jan 20, 2019
1,042 views
What is the time complexity of the following recurrence relation and step to derive the same$T(n) = T(\sqrt{n}) + log(logn)$