Properties of Big O Notation

Below are some important Properties of Big O Notation:

1. Reflexivity:

For any function f(n), f(n) = O(f(n)).

Example:

f(n) = n2, then f(n) = O(n2).

2. Transitivity:

If f(n) = O(g(n)) and g(n) = O(h(n)), then f(n) = O(h(n)).

Example:

f(n) = n3, g(n) = n2, h(n) = n4. Then f(n) = O(g(n)) and g(n) = O(h(n)). Therefore, f(n) = O(h(n)).

3. Constant Factor:

For any constant c > 0 and functions f(n) and g(n), if f(n) = O(g(n)), then cf(n) = O(g(n)).

Example:

f(n) = n, g(n) = n2. Then f(n) = O(g(n)). Therefore, 2f(n) = O(g(n)).

4. Sum Rule:

If f(n) = O(g(n)) and h(n) = O(g(n)), then f(n) + h(n) = O(g(n)).

Example:

f(n) = n2, g(n) = n3, h(n) = n4. Then f(n) = O(g(n)) and h(n) = O(g(n)). Therefore, f(n) + h(n) = O(g(n)).

5. Product Rule:

If f(n) = O(g(n)) and h(n) = O(k(n)), then f(n) * h(n) = O(g(n) * k(n)).

Example:

f(n) = n, g(n) = n2, h(n) = n3, k(n) = n4. Then f(n) = O(g(n)) and h(n) = O(k(n)). Therefore, f(n) * h(n) = O(g(n) * k(n)) = O(n5).

6. Composition Rule:

If f(n) = O(g(n)) and g(n) = O(h(n)), then f(g(n)) = O(h(n)).

Example:

f(n) = n2, g(n) = n, h(n) = n3. Then f(n) = O(g(n)) and g(n) = O(h(n)). Therefore, f(g(n)) = O(h(n)) = O(n3).

Big O Notation Tutorial – A Guide to Big O Analysis

Big O notation is a powerful tool used in computer science to describe the time complexity or space complexity of algorithms. It provides a standardized way to compare the efficiency of different algorithms in terms of their worst-case performance. Understanding Big O notation is essential for analyzing and designing efficient algorithms.

In this tutorial, we will cover the basics of Big O notation, its significance, and how to analyze the complexity of algorithms using Big O.

Table of Content

  • What is Big-O Notation?
  • Definition of Big-O Notation:
  • Why is Big O Notation Important?
  • Properties of Big O Notation
  • Common Big-O Notations
  • How to Determine Big O Notation?
  • Mathematical Examples of Runtime Analysis
  • Algorithmic Examples of Runtime Analysis
  • Algorithm Classes with Number of Operations and Execution Time
  • Comparison of Big O Notation, Big Ω (Omega) Notation, and Big θ (Theta) Notation
  • Frequently Asked Questions about Big O Notation

Similar Reads

What is Big-O Notation?

Big-O, commonly referred to as “Order of”, is a way to express the upper bound of an algorithm’s time complexity, since it analyses the worst-case situation of algorithm. It provides an upper limit on the time taken by an algorithm in terms of the size of the input. It’s denoted as O(f(n)), where f(n) is a function that represents the number of operations (steps) that an algorithm performs to solve a problem of size n....

Definition of Big-O Notation:

Given two functions f(n) and g(n), we say that f(n) is O(g(n)) if there exist constants c > 0 and n0 >= 0 such that f(n) <= c*g(n) for all n >= n0....

Why is Big O Notation Important?

Big O notation is a mathematical notation used to describe the worst-case time complexity or efficiency of an algorithm or the worst-case space complexity of a data structure. It provides a way to compare the performance of different algorithms and data structures, and to predict how they will behave as the input size increases....

Properties of Big O Notation:

Below are some important Properties of Big O Notation:...

Common Big-O Notations:

Big-O notation is a way to measure the time and space complexity of an algorithm. It describes the upper bound of the complexity in the worst-case scenario. Let’s look into the different types of time complexities:...

How to Determine Big O Notation?

Big O notation is a mathematical notation used to describe the asymptotic behavior of a function as its input grows infinitely large. It provides a way to characterize the efficiency of algorithms and data structures....

Mathematical Examples of Runtime Analysis:

Below table illustrates the runtime analysis of different orders of algorithms as the input size (n) increases....

Algorithmic Examples of Runtime Analysis:

Below table categorizes algorithms based on their runtime complexity and provides examples for each type....

Algorithm Classes with Number of Operations and Execution Time:

Below are the classes of algorithms and their execution times on a computer executing 1 million operation per second (1 sec = 106 μsec  = 103 msec):...

Comparison of Big O Notation, Big Ω (Omega) Notation, and Big θ (Theta) Notation:

Below is a table comparing Big O notation, Ω (Omega) notation, and θ (Theta) notation:...

Frequently Asked Questions about Big O Notation:

Question 1. What is Big O Notation?...

Related Article:

Examples of Big-O analysisDesign and Analysis of AlgorithmsTypes of Asymptotic Notations in Complexity Analysis of AlgorithmsAnalysis of Algorithms | Big – Ω (Big- Omega) NotationAnalysis of Algorithms | little o and little omega notations...

Contact Us