Algorithm complexity can be represented by Big O notation, for example, the following piece of code has
s = 0
arr = [1, 2, 3, 4, 5]
for i in arr:
s += i
How do we know which is better: If we have
Therefore,
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:
If
Given the above example,
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Sign Area of Irregular Polygon
Next Post: Codeforces: 239A. Two Bags of Potatoes