→ Big 0 Notation is way to formalize fuzzy counting

→ It allows us to talk formally about how the runtime of an algorithm grows as the inputs grow

→ The relationship between the input size and time relative to the input.

→ We won’t care about the details only the trends

Big 0 Definition — upper case

Big O Definition refers to the formal mathematical way of expressing how the runtime of an algorithm grows relative to its input size. It states that an algorithm is O(f(n)) if the number of operations a computer performs is eventually less than a constant times f(n) as the input size (n) increases. This provides a standardized way to analyze and compare algorithm efficiency.

We say that an algorithm is O(f(n)) if the number of simple operations a computer has to do is eventually less than a constant times f(n), as n increases.

Examples

function addUpTo(n){
	return n * (n + 1) /2;
}
time complexity - O(1)

image.png

function addUpTo(n){
	let total = 0;
	for(let i = 1;i <= n; i++){
		total += i;
	}
	return total;
}
time complexity - O(n)
Number of operations is (eventually) be bounded by multiple of n