Answer to Question #197063 in Algorithms for greeshma

Question #197063

Calculate the time complexity of the following program fragments.

(a) π‘“π‘œπ‘Ÿ (𝑖 = 1; 𝑖 ≀ 𝑛; 𝑖 βˆ— = 2)

{

π‘₯ = π‘₯ + 1

}

(b) π‘“π‘œπ‘Ÿ (𝑖 = 1; 𝑖 ≀ 𝑛; 𝑖 + +)

π‘“π‘œπ‘Ÿ (𝑗 = 1; 𝑗 ≀ 𝑛; 𝑗 = 𝑗 βˆ— 2)

{

… .

… .

}


1
Expert's answer
2021-05-23T14:37:53-0400

a)

"T(n)=\\lfloor log_2(n)\\rfloor"


b)

"T(n)=n\\lfloor log_2(n)\\rfloor"


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

Assignment Expert
24.05.21, 14:47

Dear greeshma,

You're welcome. We are glad to be helpful.Β 

If you liked our service please press like-button beside answer field. Thank you!



greeshma
24.05.21, 07:26

Thank you so much

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS