Data Structures - Asymptotic Analysis
Data Structures - Asymptotic Analysis
Asymptotic Analysis
Asymptotic analysis of an algorithm refers to defining the mathematical
foundation/framing of its run-time performance. Using asymptotic analysis, we can very
well conclude the best case, average case, and worst case scenario of an algorithm.
AD
Asymptotic Notations
Execution time of an algorithm depends on the instruction set, processor speed, disk I/O
speed, etc. Hence, we estimate the efficiency of an algorithm asymptotically.
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 1/7
Page 2 of 7
O − Big Oh Notation
Ω − Big omega Notation
o − Little Oh Notation
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
AD
A function f(n) can be represented is the order of g(n) that is O(g(n)), if there exists a
value of positive integer n as n0 and a positive constant c such that −
Hence, function g(n) is an upper bound for function f(n), as g(n) grows faster than
f(n).
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 2/7
Page 3 of 7
Example
Considering g(n) = n3 ,
We say that f (n) = Ω(g(n)) when there exists constant c that f (n) ⩾ c. g(n) for all
sufficiently large value of n. Here n is a positive integer. It means function g is a lower
bound for function f ; after a certain value of n, f will never go below g.
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 3/7
Page 4 of 7
Example
We say that f (n) = θ(g(n)) when there exist constants c1 and c2 that
c1 . g(n) ⩽ f (n) ⩽ c2 . g(n) for all sufficiently large value of n. Here n is a positive integer.
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 4/7
Page 5 of 7
Example
Considering g(n) = n3 , 4.g(n) ⩽ f (n) ⩽ 5.g(n) for all the large values of n.
Little Oh, o
The asymptotic upper bound provided by O-notation may or may not be asymptotically
tight. The bound 2.n2 = O(n2 ) is asymptotically tight, but the bound 2.n = O(n2 ) is not.
We formally define o(g(n)) (little-oh of g of n) as the set f(n) = o(g(n)) for any
positive constant c > 0 and there exists a value n0 > 0, such that 0 ⩽ f (n) ⩽ c. g(n).
Intuitively, in the o-notation, the function f(n) becomes insignificant relative to g(n) as
n approaches infinity; that is,
f (n)
lim =0
n→∞ ( g(n) )
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 5/7
Page 6 of 7
Example
Considering g(n) = n4 ,
Little Omega, ω
We use ω-notation to denote a lower bound that is not asymptotically tight. Formally,
however, we define ω(g(n)) (little-omega of g of n) as the set f(n) = ω(g(n)) for any
positive constant C > 0 and there exists a value n0 > 0, such that 0 ⩽ c. g(n) < f (n).
2
n2
For example, n = ω(n) , but ≠ ω(n2 ) . The relation f (n) = ω(g(n)) implies that the
2 2
following limit exists
f (n)
lim =∞
n→∞ ( g(n) )
That is, f(n) becomes arbitrarily large relative to g(n) as n approaches infinity.
Example
Considering g(n) = n2 ,
constant − O(1)
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 6/7
Page 7 of 7
logarithmic − O(log n)
linear − O(n)
quadratic − O(n2)
cubic − O(n3)
polynomial − nO(1)
exponential − 2O(n)
In Apriori, it is the reason that we use asymptotic notations to determine time and space
complexity as they change from computer to computer; however, asymptotically they are
the same.
https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm?authuser=0 7/7