×

Asymptotic Notation

Asymptotic notation is expressions that are used to represent the complexity of algorithms. The complexity of the algorithm is analyzed from two perspectives: 

  1. Time complexity
  2. Space complexity

Time complexity

The time complexity of an algorithm is the amount of time the algorithm takes to complete its process. Time complexity is calculated by calculating the number of steps performed by the algorithm to complete the execution.

Space complexity

The space complexity of an algorithm is the amount of memory used by the algorithm. Space complexity includes two spaces: Auxiliary space and Input space. The auxiliary space is the temporary space or extra space used during execution by the algorithm. The space complexity of an algorithm is expressed by Big O (O(n)) notation. Many algorithms have inputs that vary in memory size. In this case, the space complexity that is there depends on the size of the input.

Different types of asymptotic notations are used to describe the algorithm complexity.

  • O? Big Oh
  • ?? Big omega
  • ?? Big theta
  • o? Little Oh
  • ?? Little omega

O- Big Oh: Asymptotic Notation (Upper Bound)

"O- Big Oh" is the most commonly used notation. Big Oh describes the worst-case scenario. It represents the upper bound of the algorithm.

Function, f(n) = O (g(n)), if and only if positive constant C is present and thus:

                              0 <= f(n) <= C(g(n))              for all n >= n0

Therefore, function g(n) is an upper bound for function f(n) because it grows faster than function f(n).

The value of f(n) function always lies below the C(g(n)) function, as shown in the graph.

Asymptotic Notation

?-Big omega: Asymptotic Notation (Lower Bound)

The Big Omega (?) notation describes the best-case scenario. It represents the lower bound of the algorithm.

Function, f(n) = ? (g(n)), if and only if positive constant C is present and thus:

                              0 <= C(g(n)) <= f(n)               for all n >= n0

The value of f(n) function always lies above the C(g(n)) function, as shown in the graph.

Asymptotic Notation

?-Big theta: Asymptotic Notation (Tight Bound)

The Big Theta (?) notation describes both the upper bound and the lower bound of the algorithm. So, you can say that it defines precise asymptotic behavior. It represents the tight bound of the algorithm.

Function, f(n) = ? (g(n)), if and only if positive constant C1, C2 and n0 is present and thus:

                           0 <= C1(g(n)) <= f(n) <= C2(g(n))                 for all n >= n0

Asymptotic Notation

o-Little Oh: Asymptotic Notation

The Little Oh (o) notation is used to represent an upper-bound that is not asymptotically-tight.

Function, f(n) = o (g(n)), if and only if positive constant C is present and thus:

                           0 <= f(n) < C(g(n))              for all n >=n0

The relation, f(n) = o(g(n)) implies that limn-? [ f(n) / g(n)] = 0.

??Little omega: Asymptotic Notation

The Little omega (?) notation is used to represent a lower-bound that is not asymptotically-tight. Function, f(n) = ?(g(n)), if and only if positive constant C is present and thus:

                           0 <= C(g(n)) < f(n)                for all n >=n0

The relation, f(n) = ?(g(n)) implies that limn-? [ f(n) / g(n)] = ?.


Related Topics

Queue Data Structure

Queue in DS: The queue is a non-primitive and linear data structure. It works on the principle of FIFO (First In First Out). That is, the element that is added...

4 minutes read.

Insertion Sort vs Bubble Sort

In this article, we will see the major differences between Insertion Sort and Bubble Sort. Before that, let’s have a quick overview of what these sorting algorithms are and what’s...

4 minutes read.

Linear vs Binary Search: Data Structure

Difference Between Linear and Binary Search What is Linear Search? A linear search also referred as a sequential search. It is a way to find an element within a list and it...

3 minutes read.

Serialize and Deserialize a Binary Tree

Implementation // Writing a C++ program to check the serialization and deserialization of binary tree.   #include <iosstream> /* A binary tree node contains a key and a pointer to the left and right...

4 minutes read.

Spanning Tree

Spanning Tree: The spanning tree is a subset of the graph. It is a non-cyclic graph. If any node in the spanning tree is truncated, the entire graph fails. There are...

10 minutes read.

What is a Threaded Binary Tree?

When we consider those binary trees that are interlinked with each other, we do come across the fact that the fields present in there do consist of NULL values that...

3 minutes read.

Vertical Order Traversal of Binary Tree

Implementation #include <iostream> #include <vector> #include <map> using namespace std; // representing the primary model of a binary tree node. struct _nod { int ky; _nod *Lft, *Rt; }; // establishing a new function representing the new binary tree node. struct _nod*...

5 minutes read.

Hashing

Hashing: Hashing is a process in which a large amount of data is mapped to a small table with the help of hashing function. It is a searching technique. Hash table We...

4 minutes read.

Binary Tree Implementation Using Arrays

Implementation Converting a binary tree into a list of arrays is one interesting problem. Let us see that in depth. In this section, we will see the implementation of the binary Trees...

4 minutes read.

Reverse a Linked List in groups of given size

Reverse a Linked List in groups of given size This article will explain how to reverse a linked list in groups of given size. Here we have given a linked list...

2 minutes read.

Linked List Representation of Binary Tree

As we all know, a binary tree has a maximum of two children and helps us manage the info correctly. The word binary itself represents its meaning; we know that...

4 minutes read.

Stack Data Structure

The stack is a non-primitive and linear data structure. It works on the principle of LIFO (Last In First Out). That is, the element that is added to the end...

3 minutes read.

B+ Tree in Data Structure

A B-Tree extension called B+ Tree, which enables effective search, insertion, and deletion operations. Both Records and keys can be stored in internal and leaf nodes in a B tree. Contrarily,...

4 minutes read.

Application of Stack in Data Structures

In this article, we will discuss all the different applications of stack. What is meant by stack? The stack is a non-primitive linear data structure in which the insertion of the new...

11 minutes read.

Length of longest palindrome in a linked list using O(1) extra space

Length of longest palindrome in a linked list using O(1) extra space In this problem, we need to find the length of the longest palindrome list that is present in given...

2 minutes read.

Convert Sorted List to Binary Search Tree

Implementation // creating the C++ implementation of the following approach: - #include <bits/stdc++.h> using namespace std; /* Create the link list node and see its implementation. */ class L__Nod { public: int record; L__Nod* next; }; /* constructing a new binary...

15 minutes read.

Operations on 2D-Arrays

Two Dimensional Array Operations Adding Elements to Two-D Arrays We must put data in both rows and columns when inserting items in 2-D Arrays. As a result, we employ the idea of...

10 minutes read.

Heap Sort in Data Structure

Heap Sort: Heap Sort is very useful and efficient sorting algorithm in data structure. We can say it is a comparison base sorting algorithm, similar sort where we will find...

2 minutes read.

Traversal of binary tree

Traversal of binary tree: A node is visited only once in the traversal of the binary tree. There are three main types of traversal methods in the binary tree. In-order traversalPre-order...

3 minutes read.

Binary Tree vs Binary Search Tree: Data Structure

Difference Between Binary Tree and Binary Search Tree What is Binary Tree? A tree which each node can have utmost two children called binary tree. These children are referred as the ‘left...

3 minutes read.