Algorithm Complexity


Algorithm complexity can be represented by Big O notation, for example, the following piece of code has tex_caa5d58969fcc95bcd6477b6782501fa Algorithm Complexity complexity that sums up the array.

s = 0
arr = [1, 2, 3, 4, 5]
for i in arr:
    s += i

How do we know which is better: If we have tex_b1e9e3820e609e93a880949b15a68ba7 Algorithm Complexity and tex_204f6dc122370ae559a6301f41029e39 Algorithm Complexity where k is a constant. We can compute its limitation. i.e.

tex_7bc311251849d92bde9ab33ab5174470 Algorithm Complexity

Therefore, tex_b1e9e3820e609e93a880949b15a68ba7 Algorithm Complexity is better than tex_204f6dc122370ae559a6301f41029e39 Algorithm Complexity.

For polynomial expressions, the highest complexity is often counted as the final complexity. For example,

s = 0
arr = [1, 2, 3, 4, 5]
for i in arr:
    s += i
cnt = [2, 3, 4, 5, 7]
for i in arr:
    for j in cnt:
        s += i * j

consists of two parts: tex_caa5d58969fcc95bcd6477b6782501fa Algorithm Complexity and tex_8fb1f5024a605dc7737c61a8a376e067 Algorithm Complexity. Therefore, the final complexity is represented by tex_37998dac4f19e782d2388e281762d317 Algorithm Complexity

If tex_e353b50bdb2642682dda041d23c51da7 Algorithm Complexity where k is a constant, therefore tex_878f71de1e4f1a6da961d533f43d026e Algorithm Complexity is the complexity of tex_f423e0c91ea450ea69cf63ef65c1030b Algorithm Complexity.

Given the above example, tex_a84aee69c8521a457244f39c434a5ade Algorithm Complexity, we can say, the overall complexity is tex_8fb1f5024a605dc7737c61a8a376e067 Algorithm Complexity.

–EOF (The Ultimate Computing & Technology Blog) —

718 words
Last Post: Sign Area of Irregular Polygon
Next Post: Codeforces: 239A. Two Bags of Potatoes

The Permanent URL is: Algorithm Complexity (AMP Version)

Leave a Reply