Big-O notation is a mathematical concept commonly utilized to describe the limiting behaviour of functions with very large inputs. Formally, it can be defined as follows:
is said to be in if there exist a real number and a natural number such that , for all .
Alternatively,
.
Example
Y axis X axis 0 0 1 1 2 2 3 3 4 4 5 5 -1 -1 1 1 2 2 Expression 1 Expression 2 Expression 3 "f" ( "n" ) Expression 5 "c" times "g" ( "n" ) "n" Subscript, 0 , Baseline Expression 8 f ( n ) f ( n ) c · g ( n ) c · g ( n ) n 0 n 0
Variants
Big Omega Notation
Big omega notation written as can effectively be thought of as the inverse of big-O notation as it is usually defined as .
Alternatively, it can be defined independently from Big-O notation as follows
is said to be in if there exist a real number and a natural number such that , for all .
Alternatively,
.
Example
Y axis X axis 0 0 1 1 2 2 3 3 4 4 5 5 -1 -1 1 1 2 2 Expression 1 Expression 2 Expression 3 "f" ( "n" ) Expression 5 "c" times "g" ( "n" ) "n" Subscript, 0 , Baseline Expression 8 f ( n ) f ( n ) c · g ( n ) c · g ( n ) n 0 n 0
Big Theta Notation
Big theta notation written as is a method for describing both the upper and lower limits of a function, and is usually defined as .
Alternatively, it can be defined independently from Big-O notation as follows
is said to be in if there exist two a real numbers and and a natural number such that , for all .
Alternatively,
.
Example
Y axis X axis 0 0 1 1 2 2 3 3 4 4 5 5 -1 -1 1 1 2 2 Expression 1 Expression 2 Expression 3 "f" ( "n" ) Expression 5 "c" Subscript, 1 , Baseline times "g" ( "n" ) Expression 7 "c" Subscript, 2 , Baseline times "g" ( "n" ) "n" Subscript, 0 , Baseline Expression 10 Expression 11 Expression 12 f ( n ) f ( n ) c 1 · g ( n ) c 1 · g ( n ) c 2 · g ( n ) c 2 · g ( n ) n 0 n 0