









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










The Course
Not a lab or programming course Not a math course, either
The “Big White Book” Second edition: now “Smaller Green Book” An excellent reference you should own
The Course
Homework: 30% Exam 1: 15% Exam 2: 15% Final: 35% Participation: 5%
The Course
CS 202 w/ grade of C- or better CS 216 w/ grade of C- or better CS 302 recommended but not required o Who has not taken CS 302?
Review: Induction
S(k) is true for fixed constant k o Often k = 0 S(n) S(n+1) for all n >= k
Proof By Induction
Show formula is true when n = k
Assume formula is true for an arbitrary n
Show that formula is then true for n+
Induction Example: Geometric Closed Form
Basis: show that a 0 = (a 0+1^ - 1)/(a - 1) a 0 = 1 = (a 1 - 1)/(a - 1) Inductive hypothesis: o Assume a 0 + a 1 + … + a n^ = (a n+1^ - 1)/(a - 1) Step (show true for n+1): a 0 + a 1 + … + a n+1^ = a 0 + a 1 + … + a n^ + a n+ = (a n+1^ - 1)/(a - 1) + a n+1^ = (a n+1+1^ - 1)/(a - 1)
Induction
Asymptotic Notation
What does O(n) running time mean? O(n 2 )? O(n lg n)? How does asymptotic running time relate to asymptotic memory usage?
Analysis of Algorithms
All memory equally expensive to access No concurrent operations All reasonable instructions take unit time o Except, of course, function calls Constant word size o Unless we are explicitly manipulating bits
Running Time
Except for time of executing a function call most statements roughly require the same amount of time o y = m * x + b o c = 5 / 9 * (t - 32 ) o z = f(x) + g(y)
Analysis
Provides an upper bound on running time An absolute guarantee
Provides the expected running time Very useful, but treat with care: what is “average”? o Random (equally likely) inputs o Real-life inputs