Asymptotic Notation: Big-O Notation (O-Notation)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Asymptotic notation

Asymptotic notations are the mathematical notations used to describe the


running time of an algorithm when the input tends towards a particular
value or a limiting value.
There are mainly three asymptotic notations:
 Big-O notation
 Omega notation
 Theta notation

Big-O Notation (O-notation)


Big-O notation represents the upper bound of the running time of an algorithm.
Thus, it gives the worst-case complexity of an algorithm.

The above expression can be described as a function f(n) belongs to the


set O(g(n)) if there exists a positive constant c such that it lies
between 0 and cg(n), for sufficiently large n.
Omega Notation (Ω-notation)
Omega notation represents the lower bound of the running time of an algorithm.
Thus, it provides the best case complexity of an algorithm.

The above expression can be described as a function f(n) belongs to the


set Ω(g(n)) if there exists a positive constant c such that it lies above cg(n), for
sufficiently large n.
Theta Notation (Θ-notation)
Theta notation encloses the function from above and below. Since it represents
the upper and the lower bound of the running time of an algorithm, it is used for
analyzing the average-case complexity of an algorithm.
The above expression can be described as a function f(n) belongs to the
set Θ(g(n)) if there exist positive constants c1 and c2 such that it can be
sandwiched between c1g(n) and c2g(n), for sufficiently large n.

BFS
BFS is a traversing algorithm where you should start traversing from a selected
node (source or starting node) and traverse the graph layerwise thus exploring
the neighbour nodes (nodes which are directly connected to source node). You
must then move towards the next-level neighbour nodes.

DFS
he DFS algorithm is a recursive algorithm that uses the idea of backtracking. It involves
exhaustive searches of all the nodes by going ahead, if possible, else by backtracking.
Topological sorting
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of
vertices such that for every directed edge u v, vertex u comes before v in the
ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.

strongly connected
A directed graph is strongly connected if there is a path between all pairs of
vertices. A strongly connected component (SCC) of a directed graph is a
maximal strongly connected subgraph
The algorithms of Kruskal and Prim 

The Bellman-Ford algorithm:


The Bellman-Ford algorithm solves the single-source shortest-paths problem in the general case in
which edge weights may be negative.

Given a weighted, directed graph G=(V; E) with source s and weight function w : E -> R, the Bellman-Ford
algorithm returns a boolean value indicating whether or not there is a negative-weight cycle that is
reachable from the source

Dijkstra’s algorithm:
Dijkstra’s algorithm solves the single-source shortest-paths problem on a weighted, directed graph G
D .V; E/ for the case in which all edge weights are nonnegative. In this section, therefore, we assume
that w.u; / 0 for each edge .u; / 2 E.

You might also like