Algorithmic Complexity
Algorithmic Complexity
Algorithmic Complexity
Algorithmic Complexity
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | ||||||
| 3 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 9 |
Difference
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | 0 | |||||
| 3 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 9 |
Difference
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | 0 | 1 | ||||
| 3 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 9 |
Difference
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | 0 | 1 | 3 | |||
| 3 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 9 |
Difference
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | 0 | 1 | 3 | 4 | 5 | 7 |
| 3 | 1 | 0 | 2 | 3 | 4 | 6 |
| 5 | 3 | 2 | 0 | 1 | 2 | 4 |
| 6 | 4 | 3 | 1 | 0 | 1 | 3 |
| 7 | 5 | 4 | 2 | 1 | 0 | 2 |
| 9 | 7 | 6 | 4 | 3 | 2 | 0 |
Difference
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| 2 | 0 | 1 | 3 | 4 | 5 | 7 |
| 3 | 1 | 0 | 2 | 3 | 4 | 6 |
| 5 | 3 | 2 | 0 | 1 | 2 | 4 |
| 6 | 4 | 3 | 1 | 0 | 1 | 3 |
| 7 | 5 | 4 | 2 | 1 | 0 | 2 |
| 9 | 7 | 6 | 4 | 3 | 2 | 0 |
|______________________|
n
n
Algorithmic Complexity
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | ||||||
| Largest? |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | |||||
| Largest? |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | |||||
| Largest? | Y |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | N | ||||
| Largest? | Y |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | N | ||||
| Largest? | Y | Y |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | N | N | N | N | N |
| Largest? | Y | Y | Y | Y | Y | Y |
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 | |
|---|---|---|---|---|---|---|
| Smallest? | Y | N | N | N | N | N |
| Largest? | Y | Y | Y | Y | Y | Y |
|______________________|
n
2
Algorithmic Complexity
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 |
|---|
Algorithmic Complexity
| 2 | 3 | 5 | 6 | 7 | 9 |
|---|
Algorithmic Complexity
Algorithmic Complexity
| Operations for n items | Approach |
|---|---|
| n2 | Compare all numbers and check for difference |
| n | Find largest and smallest numbers then calculate difference |
| 3 | Compare first and last numbers and calculate difference |
Algorithmic Complexity
So why isn't this 2(n)???
| Operations for n items | Approach |
|---|---|
| n2 | Compare all numbers and check for difference |
| n | Find largest and smallest numbers then calculate difference |
| 3 | Compare first and last numbers and calculate difference |
Algorithmic Complexity
General Complexity Types:
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Very Good
Very Bad
Algorithmic Complexity
General Complexity Types:
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Grows Slowly
Grows Quickly
Algorithmic Complexity
General Complexity Types:
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Grows Slowly
Grows Quickly
Algorithmic Complexity
General Complexity Types:
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Grows Slowly
Grows Quickly
Algorithmic Complexity
| Name | Constant | ||||
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<___________________________________________________________________>
T
I
M
E
n
Algorithmic Complexity
| Name | Constant | Logarithmic | |||
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<___________________________________________________________________>
T
I
M
E
n
Algorithmic Complexity
| Name | Constant | Logarithmic | Linear | ||
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<___________________________________________________________________>
T
I
M
E
n
Algorithmic Complexity
| Name | Constant | Logarithmic | Linear | Quadriatic | |
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<___________________________________________________________________>
T
I
M
E
n
Algorithmic Complexity
| Name | Constant | Logarithmic | Linear | Quadriatic | Exponential |
| Big O | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<____________________________________________________________________>
T
I
M
E
n
Algorithmic Complexity
General Complexity Types:
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Grows Slowly
Grows Quickly
Algorithmic Complexity
| Notation | O(1) | O(log n) | O(n) | O(n2) | O(cn) |
<______________________________________________________>
Grows Slowly
Grows Quickly
Algorithmic Complexity
Practice with this quiz:
http://www.codequizzes.com/computer-science/big-o-algorithms