Algorithms | Analysis of Algorithms | Question 1
What is time complexity of fun()?
For an input integer n, the innermost statement of fun() is executed following times. n + n/2 + n/4 + … 1
So time complexity T(n) can be written as T(n) = O(n + n/2 + n/4 + … 1) = O(n)
The value of count is also n + n/2 + n/4 + .. + 1
Quiz of this Question
Please comment below if you find anything wrong in the above post
My Personal Notes arrow_drop_up
Please Login to comment...