Big O Notation
Big O represents the running time as a function of the size of the input (N).
We simplify to just the highest order term, and ignore constant coefficients of N.
Examples:
Formal definition:
Basically: f(n) worst case is g(n), so f(n) will be the same or faster than g(n).

An example:
int max(int items[], int size) { // Running time is O(N)
int largest = items[0];
for(inti=0; i<size; i++)
if (items[i] > largest)
largest = items[i];
return largest;
}
Last updated
Was this helpful?