Gregory M. Kapfhammer

Introduction to Computer Science II

Office Hours, Email, Web, Twitter

Algorithms

Correctness

Performance

How *fast* is an algorithm?

Try some *examples*!

Constant

Linear

Quadratic

Cubic

git pull

CLASSPATH

Compile

Algorithm

Function

Draw a *Graph*

Function *Exploration*

Add in exponential

Add in factorial

Plot the functions

Create a table of values

Conclusions?

Implications?

Take a step back

Direct Comparison

Limited Inputs

Fully Implemented

Characterize *programs* as functions of *input* size

Hands-on Example

Largest Integer?

Largest Double?

How did you determine?

Computing Sums

Correct?

Incorrect?

Conduct an *Experiment*

Why?

Pseudo code

When *n* gets big

Revisit computing sums

Best, Worst, Average

f(n) *is* O(g(n))

f(n) is *O*(g(n))

f(n) is O(*g(n)*)

Does this *really* matter?

Composing Long Strings

String *concatenation*

`git pull`

Which is faster?

repeat1 vs. repeat2

Why?

Additional examples

ArrayMax

ArrayFind

Worst-Case time complexity?

Why?

Run an experiment

Analysis confirmed?