• retagged by
740 views

2 Answers

3 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 1 vote

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)

Position:
Show:

Related questions

1 1 vote
2 answers 2 answers
837
837 views
Utk asked Jan 20, 2016
837 views
$T(n)=2T(\frac{n}{2})+n\log n$ for n>=2 and T(1)=0, then T(n) is(a.) $O(n)$(b.) $O(n \log n)$(c.) $O( n (\log n)^{2})$(d.) $O(n^{2})$ Answer given is (c.) The solution is...
1 1 vote
0 0 answers
2.2k
2.2k views
syncronizing asked Mar 15, 2019
2,233 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 1 vote
1 1 answer
1.7k
1.7k views
VikramRB asked Jan 20, 2019
1,727 views
What is the time complexity of the following recurrence relation and step to derive the same$T(n) = T(\sqrt{n}) + log(logn)$
1 1 vote
1 1 answer
6.2k
6.2k views
gmrishikumar asked Nov 22, 2018
6,238 views
int A(int n){ for(i = 1; i < n; i++) for(j = 1; j < i; j *= 2) for(k = j; k >= 1; k /= 2) if(n = 0) return 1; else...