Skip to content

Instantly share code, notes, and snippets.

@sebleier
Created December 13, 2011 19:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebleier/1473587 to your computer and use it in GitHub Desktop.
Save sebleier/1473587 to your computer and use it in GitHub Desktop.
Big-Q notation

Big-Q Notation

Big-Q notation is exactly the same as Big-O notation, except for the understanding that the constant multiplier for the asymptotic bound function is greater.

For example Big-O is defined as:

f(x) <= C * g(x) 

Big-Q notation could be defined as:

f(x) <= C' * g(x)

Here we have the understanding that typically, but not absolutely, that 1 < C < C'

Why is this useful?

When describing the performance of a web app, it would be useful to use different notations to describe different kinds of work being performed. Using that information, one could better identify bottlenecks in the code.

For instance, iterating through a list is an O(n) operation. However, if you perform a query for every iteration of that list, the cost of the operation would be denoted as O(n) + Q(n). In big-O notation, this would just be a * O(n) + b * O(n), where b > a and would reduce to O(n). This loses the feeling that your algorithm is I/O bound by database queries.

To make the most of the notation, I would recommend that web app views always be described by big-O and big-Q components.

@chrisdickinson
Copy link

👍

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