20 lines
1.6 KiB
Markdown
20 lines
1.6 KiB
Markdown
### Running Time
|
|
Most Algorithms transform input objects into output objects. The running time typically grows with the input size. Average case time is often difficult to determine. We focus on the worst case running time, as it's easier to analyze and its crucial to applications such as games, finance, and robotics.
|
|
### Space Complexity
|
|
In algorithms, you need to think about the amount of space, memory, that you need to compute the algorithm.
|
|
### Algorithm Structure?
|
|
Need to think about how complex an algorithm is in implementation, the simpler the better. Code organization is also important in the structure.
|
|
### Fibonacci
|
|
Algorithm which uses array to store previous fib numbers vs one which uses constant number of variables to compute the sequence. Space complexity varies between the two between one being O(n) and one is O(1).
|
|
|
|
The naive recursive solution for this problem is very bad. By using multiple return values we can make the recursive algorithm equal to the non-recursive algorithm.
|
|
### Counting Primitive Operations
|
|
The algorithm described is a simple implementation to find the max value of an array containing only numbers
|
|
|
|
By inspecting the pseudo-code, we can determine the maximum number of primitive operations executed by an algorithm, as a function of the input size.
|
|
|
|
Looking at the number of times n is used, in the worst case scenario, we can see a for loop, as well as other stuff? ending up with a number of operations of 8n-2, with a big O of O(n)
|
|
|
|
### Relatives of Big O,
|
|
- Big Omega
|
|
- Big Theta - If this is n squared, it means big omega and big o are also n squared. |