Skip to content

Instantly share code, notes, and snippets.

@byelipk
Created June 5, 2017 14:23
Show Gist options
  • Save byelipk/1a2aeb505a834d38a74876ffd330c04f to your computer and use it in GitHub Desktop.
Save byelipk/1a2aeb505a834d38a74876ffd330c04f to your computer and use it in GitHub Desktop.
Common time complexity operations

O(1)

This denotes constant time. Running a statement like if (true) {...} is constant time. Another example of constant time is looking up a value in an object, array, or a hash table.

O(log n)

This denotes logrithmic time. Divide and conquer or recursive algorithms have a O(log n) time complexity.

O(n)

This denotes linear time. Whenever we loop through values of an array, that process has a linear time complexity.

O(n log n)

This denotes linearithmic time complexity. An example of this is merge sort, which features recursion with a binary split.

O(n^2)

This denotes quadratic time. Think double nested loops.

O(n^3)

This denotes exponential time. Think triply nested loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment