×

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

Given a Binary Tree Check the Zig-Zag Traversal

Implementation // The C++ implementation of the zig-zag traversal method in the O(n) time.  #include <iostream> #include <stack> using namespace std; // creating a binary tree node. struct __nod { int record; struct __nod *Lft, *Rt; }; // creating a...

4 minutes read.

Tree vs Graph: Data Structure

Difference Between Tree and Graph What is Tree? A tree is a non-linear data structure and finite collection of elements called node. A tree, in which the data items are arranged in...

3 minutes read.

Tree terminology in Data structures

Data structures The storage used to organize and store data is known as a data structure, and it is a method where data can be arranged on a computer to be...

6 minutes read.

Advantages and Disadvantages of Linked List

Advantages of Linked List The linked list is a dynamic data structure.You can also decrease and increase the linked list at run-time. That is, you can allocate and deallocate memory at...

3 minutes read.

Convert binary tree to a doubly linked list

Implementation //creating a C++ program for the transition of a binary tree into a linked list. #include <iostream> using namespace std; /* Firstly, let’s create a binary tree that will help us in setting...

4 minutes read.

Delete nodes from the linked list which have a greater value on the right side

Delete nodes from the linked list which have a greater value on the right side In this problem, we have given a singly linked list, and we need to remove all...

3 minutes read.

Dijkstra’s vs Bellman-Ford Algorithm

The Dijkstra Algorithm One of the SSSP (Single Source Shortest Path) algorithms is Dijkstra's. As a result, it finds the shortest path between a source node and all other nodes in...

7 minutes read.

What Should We Learn First? Trees or Graphs in Data Structures

A data structure is a database used to store and manage data and optimize and manage computing resources. A data structure is a form used intelligently and quickly to store,...

6 minutes read.

Permutation Sort or Bogo Sort

In Permutation Sort or Bogo Sort, you have been given one array, which consists of different values. You have to sort the array using BOGO sort. Let’s take an example: Input-...

3 minutes read.

What is the difference between Tree and Graph

We usually use a diverse range of data structure to store our data and information. To store them in a more sequential manner and to access them easily, we use...

4 minutes read.

Trim a binary search tree

Implementation //writing a C++ program will help us eliminate the keys that are out of the league.  #include<bits/stdc++.h> using namespace std; //we are now creating a binary search tree node consisting of key left...

8 minutes read.

What is a Spanning Tree in Data Structure

Data structures Data management is called database management. This allows the computer to sort or organize the data for efficient retrieval. A data model is a system used to store, manage,...

5 minutes read.

Finding Rank in a Binary Search Tree

Implementation // writing a C++ program to find out the rank and element in the program.  #include <bits/stdc++.h> using namespace std; struct __nod { int record; __nod *Lft, *Rt; int LftSize; }; __nod* new__nod(int record) { __nod *temp = new __nod; temp->record...

6 minutes read.

Rotate a Singly Linked List

Rotate a Singly Linked List This article will explain how we can rotate the singly linked list. Here we have given a singly linked list, and we need to rotate this...

4 minutes read.

Linked List Data Structure

Linked list in DS: The linked list is a non-primitive and linear data structure. It is a list of a particular type of data element that is connected to each...

3 minutes read.

Array vs Linked List: Data Structure

Data structure: Difference Between Array and Linked List What is Array? An array is a linear data structure that can store similar data items for further processing. The similar data items...

3 minutes read.

Binary Tree in Data Structures

What is a Binary Tree in Data Structures? The term binary itself means bi, which implies two of anything. So very clearly, we know we present the trees in the form...

6 minutes read.

Types of Linked list

Single linked list  A single linked list is a linked list in which all nodes are connected with each other in sequence. Each node of a singly linked list has two...

7 minutes read.

Primitive Data Structure in C

The data structure is a logical or mathematical model for organizing and structuring the main memory or elements. We can classify the data structures in two ways one is primitive, and...

10 minutes read.

Complete Binary tree

In this article, we will discuss the complete binary tree. But before start discussing the complete binary tree, we should first see a brief description of a binary tree. What is...

7 minutes read.