Commit 3e3a57d3 authored by Eric Krawczyk's avatar Eric Krawczyk
Browse files

added second lecture notes

parent 7b9ac582
## EECS 281 - 10 SEP 2015
### Complexity, Runtime, Pseudocode
# EECS 281 - 10 SEP 2015
## Make, Complexity, Runtime
#### Introductions
- survey on ctools test center
......@@ -63,3 +63,73 @@
- `make profile` some other fucking shit
- `make_tests` to make exes for test* files
- only creates .o files if older than .cpp, then rebuild to .o, else naw
- dependencies
- build target is a .o files
- don't compile .h files
- make commands
- all/release
- DEBUG
- profile
- cleanuptest_class
- alltest
- partialsubmit
- fullsubmit
#### Runtime
- What affects runtime?
- algorithm
- implementation
- cpu/mem speed
- compiler opts
- `-g` flag for debug
- `-O3` flag for optimization lvl 3
- parallel processes
- **Amount of data processed (input size)**
- measuring input size
- *`n`* input size
- *`f(n)`* max number of steps taken by algorithm w/ input of length n
- *`O(f(n))`* Big O notation - upper bounds of runtime
- example:
- given 2D array, what's the most efficient way to process the array?
- by row, then by col
- innermost var changest quickest
- EXAMPLE
```c++
int a[100][100]
for (int i = 0; ...)
for (int j = 0; ...
cin >> a[i][j]
```
- eg: 3d array, read in order of col, then row, then floor
- What counts as a "step"?
- primitive operations
- assign var
- arithmetic `+ - / *`
- comparison `==`
- pointer/array index
- Fn call (excluding data)
- Fn return (excluding data)
- runtime of 1 step is independent of input
- Counting steps
- see lecture slide for code (`02_Complexity_Analysis.pdf` slide 9)
- for loop
- init performed once: `1`
- one comparison for each iteration, plus last one `n+1`
- update every iteration `n`
- total `1+1+2*n`
- Big O notation
- review your shit from 203
- upper bound
- f(n) = O(g(n)) iff constants
- `c > 0`
- `n0 >= 0`
- such that `f(n) <= c g(n)` whenever `M >= n0`
- Exercises
- see `02_Complexity_Analysis.pdf` slide 19
- true
- true
- false
- true
- false
- true
- false
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment