Answer to Question #186502 in Algorithms for Zahra

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)=\\Sigma_{i=1}^{i=n} \\Sigma_{j=1}^{n-1} (1)"

We know that,

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

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

Now again,

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

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

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

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


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

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

"=\\frac{1}{2}O(n^2)-\\frac{3}{2}O(n)"

Hence the required final complexity will be "=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

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS