Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Last active July 17, 2023 12:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/fe56e0b347570f6c517f2d5309ed468d to your computer and use it in GitHub Desktop.
Save remarkablemark/fe56e0b347570f6c517f2d5309ed468d to your computer and use it in GitHub Desktop.
Common order-of-growth classifications

Common order-of-growth classifications

order of growth name code example description example T(2N) / T(N)
1 constant a = b + c statement add 3 numbers 1
log N logarithmic while (N > 1)
{ n = N / 2; }
divide in half binary search ~ 1
N linear for (i = 0; i < N; i++)
{ /* ... */ }
loop find the maximum 2
N log N linearithmic [mergesort] divide and conquer mergesort ~ 2
N^2 quadratic for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
{ /* ... */ }
double loop check all pairs 4
N^3 cubic for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
for (k = 0; k < N; k++)
{ /* ... */ }
triple loop check all triples 8
2^N exponential [combinatorial search] exhaustive search check all subsets T(N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment