Algorithms | Analysis of Algorithms | Question 9
In a competition, four different functions are observed. All the functions use a single for loop and within the for loop, same set of statements are executed. Consider the following for loops:
If n is the size of input(positive), which function is most efficient(if the task to be performed is not an issue)?
The time complexity of the first for loop is O(n).
The time complexity of the second for loop is O(n/2), equivalent to O(n) in asymptotic analysis.
The time complexity of the third for loop is O(log(n)).
The fourth for loop doesn’t terminate.
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...