edited by
209 views
0 votes
0 votes
i=n;

while(i>0)

{

j=1;

while(j<=n)

{

j=2*j;

}

i=i/2;

}
edited by

1 Answer

0 votes
0 votes
The first while loop runs O(logn) times. for each outer loop inner runs O(logn) times.So.the time complexity is O(logn)*O(logn)=O((logn)^2)

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()$ ?