2.1 Lecture 2
2.1 Lecture 2
Asymptotic notation
Analysis of Time complexity
• Best case:. The best-case complexity of the algorithm is the
function defined by the minimum number of steps taken on any
instance of size n for particular problem.
• Particular input Minimum time required for program execution.
• Average case: The Average -case complexity of the algorithm is
the function defined by the minimum number of steps taken on
any instance of size n.
• Worst case: The worst-case complexity of the algorithm is the
function defined by the maximum number of steps taken on any
instance of size n, Minimum time required for program
execution.
Example of Linear Search
• A[10]={1,2,4,7,9,11,13,16,18,19}
• X=1, best case
• X=19/21 worst case
• X=11 average case
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: The time complexity of an
algorithm is the amount of time the algorithm takes to complete
its process.
Why is Asymptotic Notation Important?
For Example:
1.1. 3n+2=O(n) as 3n+2≤4n for all n≥2
2.2. 3n+3=O(n) as 3n+3≤4n for all n≥3
Ω-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
Ω-Big omega
3n+2= θ (n) as 3n+2≥3n and 3n+2≤ 4n, for n c1=3,c2=4, and n0=2
Common Asymptotic Notations
Following is a list of some common
asymptotic notations −
constant − Ο(1)
logarithmic − Ο(log n)
linear − Ο(n)
n log n − Ο(n log n)
2
quadratic − Ο(n )
3
cubic − Ο(n )
Ο(1)
polynomial − n
Ο(n)
exponential − 2