Algorithm - qyjohn/Hands-on-Linux GitHub Wiki

Basic Maths

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

Sorting

Algorithm Best Case Worse Case Average Case
Insertion Sort n n2 n2
Quick Sort n*log(n) n2 n*log(n)

Searching

Algorithm Average/Worse Case Best Case
Binary Search (sorted array) log(n) 1
Binary Search Tree n h -> height of the tree
⚠️ **GitHub.com Fallback** ⚠️