Algorithm - qyjohn/Hands-on-Linux GitHub Wiki
The sum of an arithmetic progression:
Sn = n * (a1 + an) / 2
When the common difference (d) in an arithmetic progress is 1, we have a1 = 1 and an = n, then:
Sn = n * (1 + n) / 2 = (n + n2) / 2
| Algorithm | Best Case | Worse Case | Average Case |
|---|---|---|---|
| Insertion Sort | n | n2 | n2 |
| Quick Sort | n*log(n) | n2 | n*log(n) |
| Algorithm | Average/Worse Case | Best Case |
|---|---|---|
| Binary Search (sorted array) | log(n) | 1 |
| Binary Search Tree | n | h -> height of the tree |