Big-O Notation
Explore the concept of Big-O notation to understand how running times of algorithms are compared based on their growth rates. Learn to interpret the definition, inequalities, and examples that highlight how functions scale and what it means for an algorithm's efficiency in terms of input size.
We'll cover the following...
Given any two functions and , when we say a function is , we are expressing a certain relationship between the two functions.
Let’s look at the definition, but don’t worry if you don’t grasp it immediately. We’ll expand on its meaning and usage bit by bit.
Definition
We say is if for some positive constants and ,
There are two inequalities above. Let’s take the one on the right first and see what it means.
The inequality on the right
First, let’s focus on the following part of the definition
for some positive constants and .
On the right-hand side of the inequality, the constant is multiplied by . Multiplication of a function by a constant is known as scaling. Scaling has the effect of changing the shape of that function.
Try choosing different values for the constant to see how the example function scales.
Coming back to our inequality, the ...