959 views

2 Answers

Best answer
4 votes
4 votes
$T(n) = \sum_{i \text { is power of 2}}^n\sum_{j \text { is power of 2}}^i T(n/2) \\= \sum_{i \text { is power of 2}}^n \lg i T(n/2) \\= T(n/2) + 2T(n/2) + 3T(n/2) + \dots + \lg n T(n/2) \\= \frac{\lg n. (\lg n + 1)}{2} T(n/2) \\= O((\lg n)^2 T(n/2)) \\= (\lg n)^2 (\lg{n/2})^2 (\lg {n/4})^2 \dots 1 \\= (\lg n .(\lg n -1). (\lg n -2) . \dots 1)^2  \\=O\left( (\lg n)!^2\right) $
selected by
0 votes
0 votes

O((log n)3)

1st for loop it will be (log n)

2nd for loop it will be again (log n)

R(n/2) it will again a log n iteration i.e. ((log n)3)

Related questions

0 votes
0 votes
0 answers
2
0 votes
0 votes
1 answer
3
NeelParekh asked Jul 27, 2023
277 views
If an array is split in the form of increasing and decreasing order then what is TC to find minimum element in the array?
2 votes
2 votes
1 answer
4
h4kr asked Dec 30, 2022
466 views
What is the correct time complexity in $\theta()$ ?