Algorithms | Analysis of Algorithms | Question 8
What is the time complexity of the below function?
At first look, the time complexity seems to be O(n2) due to two loops. But, please note that the variable j is not initialized for each value of variable i. So, the inner loop runs at most n times. Please observe the difference between the function given in the question and the below function:
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...