Lecture 13 Efficiency
- Questions
- Measuring efficiency
- How much resource consumption a computation task takes
- We are concerned with time and space efficiency
- Time efficiency
- how long to wait
- Memory Efficiency
- how much memory running your application takes
- Orders of Growth
- Prepend
- Adding something to the end of a list
- Exponentiation
- We don’t really care about the values, more that the computation is linear
- Logarithmic exponentiation
- Quadratic Time
- Exponential Time
- Common Orders of Growth
- Exponential growth
- fibonaci
- Quadratic
- overlap
- Linear
- slow exp
- Logarithmic growth
- exp_fast
- Constant growth
- increasing n doesn’t affect time
- Order of Growth Notation
- Big Theta and Big O Notation for Orders of Growth
- BigO represents the worst case
- O(b^n)
- O(n^2)
- O(log n)
- Big Theta is average case
- Space Usage
- Space and Environments
- At any moment, there is a set of active environments
- Values and frame in active environments consume memory
- We can close frames once we know their return value
- Space consumption
- The longest path (depth) of the tree of fib
- Generators are lazy
- They save space when we use them because they don’t need to compute everything
3.