Define the Time complexity of the following piece of code: 1) 2) for(int i = n; i > 0; i/= 2) { for(int j = 1; j 0; j = 2) { for (k=j; k0; i--) { for(int j = 1; j

icon
Related questions
Question
100%
Can I get some help here finding time complexity please?
4)
... // constant number C of operations
let a = 0, b = 0;
for (let i = 0; i<n; ++i)
{
for (let j = 0; j<n; ++j)
{
}
a = a + j;
}
for (let k = 0; k<n; ++k)
{
b=b+k;
}
5) f(n)= 05 +0.001n³+0.025n+ 3 logs n + log2 log2 log2 n
6) g(n)= 500n + 100n¹5 + 50n logio n + n log3 n + n log₂ n
7) h(n)= 100n log³ n+n³ + 100n +0.003 log4 n + log2 log₂ n
Transcribed Image Text:4) ... // constant number C of operations let a = 0, b = 0; for (let i = 0; i<n; ++i) { for (let j = 0; j<n; ++j) { } a = a + j; } for (let k = 0; k<n; ++k) { b=b+k; } 5) f(n)= 05 +0.001n³+0.025n+ 3 logs n + log2 log2 log2 n 6) g(n)= 500n + 100n¹5 + 50n logio n + n log3 n + n log₂ n 7) h(n)= 100n log³ n+n³ + 100n +0.003 log4 n + log2 log₂ n
Define the Time complexity of the following piece of code:
1)
2)
for(int i = n; i > 0; i/= 2)
{
for(int j = 1; j<n; j *= 2)
{
}
for(int k = 0; k<n; k += 2)
{
... // constant number of operations
}
for (i=1;i<n; i *= 2)
{
for(j=n; j> 0; j /= 2)
{
for (k=j; k<n; k += 2 )
{
sum + (i + j* k);
}
}
}
3) Assuming that n = 2m:
for(int i = n; i >0; i--)
{
for(int j = 1; j<n; j *= 2 )
{
for(int k = 0; k<j; k++)
Transcribed Image Text:Define the Time complexity of the following piece of code: 1) 2) for(int i = n; i > 0; i/= 2) { for(int j = 1; j<n; j *= 2) { } for(int k = 0; k<n; k += 2) { ... // constant number of operations } for (i=1;i<n; i *= 2) { for(j=n; j> 0; j /= 2) { for (k=j; k<n; k += 2 ) { sum + (i + j* k); } } } 3) Assuming that n = 2m: for(int i = n; i >0; i--) { for(int j = 1; j<n; j *= 2 ) { for(int k = 0; k<j; k++)
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer