Algorithm Analysis
Algorithm Analysis
Objectives
• Why is algorithm analysis important
• Be able to use Big-O to describe execution
time
• Know the common Big-O categories
• Understand Big-O timing for common
operations on lists and dictionaries in Python
• Know how to measure (benchmark) simple
python programs
Compare two programs for adding:
1 + 2 + 3 + 4 +… + n
Algorithm B:
times for n = 10,000, 100,000, 1,000,000, 100,000,000
Sum up to 10000 required 0.0000012 seconds
Sum up to 100000 required 0.0000010 seconds
Sum up to 1000000 required 0.0000010 seconds
Sum up to 100000000 required 0.0000041 seconds
Summation symbol
T(n) = 3 + 4n2 + 3n + 1
= 4n2 + 3n + 4
is O(n2)