algorithm - Big-O complexity for this loop -
What is the biggest complexity of the following loop:
for each vertical? ??? C do it for every top ??? C and V & gt; U do What I'm doing here, imagine the following set {1,2,3,4} loop executes a function for all combinations of 2 elements of this number Is (1,2), (1,3), (1,4), (2,3), (2,4), (3,4).
Is it = (n ^ 2) where is the number of elements in n set?
Yes, this o (n ^ 2) , recognizes the function implemented O (1) , of course, and the iterator is also on the average repetition of o (1) (which is usually a valid assumption). Note that if you also customize it further, then select (n, 2) elements, and select (n, 2) = n ( N-1) / 2 , which is still O (n ^ 2) .
Comments
Post a Comment