1.3 Complexity Analysis of Algorithms - Big O, Omega, and Theta Notation
1.3 Complexity Analysis of Algorithms - Big O, Omega, and Theta Notation
The word Asymptotic means
approaching a value or curve arbitrarily
closely (i.e., as some sort of limit is
taken).
Asymptotic notations are mathematical
tools to represent time complexity of
algorithms for asymptotic analysis.
we evaluate the performance of an algorithm
in terms of input size (we don’t measure the
actual running time)
AAD CSE SRM-AP 6
Asymptotic Analysis
The simplest example is a function ƒ (n) = n2+3n,
the term 3n becomes insignificant compared
to n2 when n is very large.
The function "ƒ (n) is said to be asymptotically
equivalent to n2 as n → ∞", and here is written
symbolically as ƒ (n) ~ n2.
Asymptotic notations are used to write fastest
and slowest possible running time for an
algorithm. These are also referred to as 'best case'
and 'worst case' scenarios respectively.
AAD CSE SRM-AP 7
Asymptotic Notations
big-Omega
f(n) is (g(n)) if f(n) is asymptotically greater than or equal to g(n)
big-Theta
f(n) is (g(n)) if f(n) is asymptotically equal to g(n)
little-oh
f(n) is o(g(n)) if f(n) is asymptotically strictly less than g(n)
little-omega
f(n) is (g(n)) if is asymptotically strictly greater than g(n)
1
1 10 100 1,000
n
Sorting Technique
Best Case Average Case Worst Case
Algorithm: Binary-Search(numbers[], x, l, r)
if l = r then
return l
else
m := ⌊(l + r) / 2⌋
if x ≤ numbers[m] then
return Binary-Search(numbers[], x, l, m)
else
return Binary-Search(numbers[], x, m+1, r)
{(
𝑐 𝑖𝑓 𝑁 =1
𝑇 ( 𝑁 )=
𝑇
𝑁
2 )
+ 1 𝑜𝑡h𝑒𝑟𝑤𝑖𝑠𝑒