November 3, 2025
Learning Objectives for Theoretical Machines
Understanding growth rates is crucial: an algorithm taking \(100n\) steps is fundamentally faster than one taking \(n^2\) steps for large \(n\). Asymptotic analysis lets proofgrammers compare algorithms meaningfully!
Growth rate comparison
Big-O notation standardizes efficiency discussions: \(5n^2 + 100n\) becomes \(O(n^2)\) because we focus on dominant terms and ignore constants. This enables meaningful comparisons across system configurations!
Common complexity classes
Dominant term examples
Practical Big-O definition
Practical Big-O examples
Formal Big-O definition
Running time analysis reveals algorithm efficiency: count how many times the innermost operations execute as a function of input size \(n\). This skill helps proofgrammers write faster, more scalable Python programs. Or, for a Turing machine, you can count how many transitions you follow! In both cases, make sure to “count” from the perspective of the worst-case input!
contains_gaga is \(O(n)\) or linear time!containsGAGA Turing machine
Running time definition
Python analysis exercise
matchingCharIndicesmatchingCharIndiceslen(word1) times, inner len(word2) timeslen(word1), \(n_2 =\) len(word2)'aaa aaaaa', the function performs \(3 \times
5 = 15\) iterations. While this analysis is not “wrong” per se it does not give the complete picture! The full analysis requires examining what happens inside each iteration, particularly the string construction operations! Let’s explore!
thisPair = str(i) + ',' + str(j).i or j to string requires \(O(log n)\) timek is \(O(log_{₁₀} k)\), so str(k) takes \(O(log k)\) time. And, importantly, the cost of append is \(O(1)\)!L the length is len(L)int!Don’t confuse size with value: the number 1000 has size \(n=4\) digits but value \(M=1000\). A loop running \(M\) times is exponential in \(n\), not linear. This mistake leads to incorrect complexity analysis! See the book’s discussion of the MCopiesOfC.py program for more details!
Trick question program called MCopiesOfC.py
Input size versus value for numbers in decimal or binary notation
Size versus value examples for integers
Factoring algorithm
Arithmetic complexity
Computational model equivalence
Proofgrammers