Complexity of a given function -
When I analyzed the complexity of the code segment below, then I found out that it o (n / 2) . But while searching on the Internet I came to know that it is probably o (n) . I want to know who is right.
zero function (int n) {int i = 1, k = 100; While (i & lt; n) {k ++; I + = 2; }}
What is the point of variation in the above method? Even though Big-O talks about behavior in the notation range (as in countless approaches from N) such that, large-O notation is both agonizing for scaling factors and constants. What is to say is equal to o (s * f (n) + c) for any constant "c" and scaling factor "s"
O (f (n))
In your case, F (N) = N, S = 1/2, and C = 0. So ...
O (N) = O (N / 2)
Comments
Post a Comment