feb 1
- go over homework; see homework
- sample C code for a tree
- sample C code for decimal to binary conversion
- dicussion of others
- start next chapter
- don't let the math freak you out; we'll do some of that but not all
- essential question: how do we measure what a good algorithm is?
size of input :
- for numbers, number of bits it takes to write it down
- but usually just the number of "things" we're given
time :
- typically number of "basic operations"
- usually what people focus on
space :
- bit harder to quantify exactly
- ... and usually there's a time/space trade-off
asymptotic behavior is what we usually cae about
1 n log(n) n*log(n) n**2 n**3 2**n n!
and in particular: EXPONENTIAL IS BAD.
worst-case vs best-case vs average-case
O(f(n)) notation :
any function that doesn't grow faster
than a multiple of f(n) as n gets big
How to do all this for specific cases?
There are two general approaches: theory (do the math and prove a result)
vs experiment (run your algorithm and see what happens)
One easy way to draw the graphs for the "run it and see"
is with gnuplot.
Example