in Algorithms retagged by
897 views
2 votes
2 votes

What is the time complexity of this code?

in Algorithms retagged by
897 views

2 Comments

A) ??
0
0
How?
0
0

1 Answer

1 vote
1 vote
Best answer
k and h will give n+logn complexity

J , k and h will give n(n+logn) complexity

I , j ,k and h will give

logn base 3(n^2+nlogn) complexity

Finally, n^2 logn base 3 + nlogn lognbase 3

Remove the negligibity and we get o(n^2) as complexity.
selected by

3 Comments

Thanks :)
0
0
I can't properly understand this step

I ,J ,K and H will give $\log_{3}n* (n^2 + n log n)$complexity

and then

I thought it will become  $\log_{3}n* (n^2 )$ + $\log_{3}n* (nlog n )$

which will be O($n^2 log_3 n$) and that equals O($n^2 log n)$.

Please correct me where I'm wrong
0
0
for comparing ,remove the common terms thus logn base3 got cancelled out,remaing is n^2 and nlogn..... most significant term is n^2.
0
0