Computer Science 112 Spring 2014
Gregory M. Kapfhammer
Introduction to Computer Science II
Keep in touch!Office Hours, Email, Web, Twitter
Algorithms
Correctness
Performance
How fast is an algorithm?
Try some examples!
for loops
Constant
Linear
Quadratic
Cubic
git pull
CLASSPATH
Compile
Run!
Results?
Conclusions?
Algorithm
Function
Draw a Graph
Slow growing
Fast
Fast growing
Slow
Function Exploration
Fastest Growth?
Slowest Growth?
Conclusions?
Implications?
Take a step back
Limitations of empirical studies
Characterize programs as functions of input size
Hands-on Example
Largest Integer?
Computing Sums
Correct?
Incorrect?
Conduct an Experiment
Efficient?
Inefficient?
Why?
Pseudo code
When n gets big
Revisit computing sums
Best, Worst, Average
Worst-Case Graph
f(n) is O(g(n))
f(n) is O(g(n))
f(n) is O(g(n))
f(n) is O(g(n))