Question #186502

Solve the following time complexity

T(n) = ∑ ∑ 1


𝑖

𝑗=0

𝑛−1

𝑖=1



1
Expert's answer
2021-04-28T11:29:57-0400

Given,

T(n)=Σi=1i=nΣj=1n1(1)T(n)=\Sigma_{i=1}^{i=n} \Sigma_{j=1}^{n-1} (1)

We know that,

Σj=1n1(1)=(n1)\Sigma_{j=1}^{n-1} (1)=(n-1)

So complexity of this step will be O(n)O(n)

Now again,

Σi=1i=n(n1)\Sigma_{i=1}^{i=n}(n-1)

=Σi=1i=n(n)Σi=1i=n(1)=\Sigma_{i=1}^{i=n}(n)-\Sigma_{i=1}^{i=n}(1)

=n(n1)2n=\frac{n(n-1)}{2}-n

=n22n2n=\frac{n^2}{2}-\frac{n}{2}-n


=n223n2=\frac{n^2}{2}-\frac{3n}{2}

So the complexity of the steps will be as per the below-

=12O(n2)32O(n)=\frac{1}{2}O(n^2)-\frac{3}{2}O(n)

Hence the required final complexity will be =O(n2)=O(n^2)


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Sawaira
29.04.21, 01:27

Thank you so much it's help me alot

LATEST TUTORIALS
APPROVED BY CLIENTS