Professional Documents
Culture Documents
Algorithms CSE 2201: Course Teacher
Algorithms CSE 2201: Course Teacher
CSE 2201
Course Teacher
http://discipline.ku.ac.bd/cse/faculty/anupam
https://www.researchgate.net/profile/Anupam_Bairagi2
https://scholar.google.co.kr/citations?user=68f3-kQAAAAJ&hl=en
Political Discussion
Sequence of
Input computational Output
steps
Example of Algorithm: Sorting Problem
Input: A sequence of n numbers: a1 , a2 ,..., an
𝑇𝑇 𝑛𝑛 = 𝑎𝑎𝑎𝑎 + 𝑏𝑏
Linear function of n
Analysis of Insertion Sort (Cont..)
Worst case: the array is already in reverse sorted order
𝑛𝑛 𝑛𝑛 + 1
𝑇𝑇 𝑛𝑛 = 𝑐𝑐1 𝑛𝑛 + 𝑐𝑐2 𝑛𝑛 − 1 + 𝑐𝑐4 𝑛𝑛 − 1 + 𝑐𝑐5 𝑛𝑛 − 1 + 𝑐𝑐5 −1
2
𝑛𝑛 𝑛𝑛 − 1 𝑛𝑛 𝑛𝑛 − 1
+ 𝑐𝑐6 + 𝑐𝑐7 + 𝑐𝑐8 𝑛𝑛 − 1
2 2
𝐶𝐶5 𝐶𝐶6 𝐶𝐶7 2 𝐶𝐶5 𝐶𝐶6 𝐶𝐶7
𝑇𝑇 𝑛𝑛 = + + 𝑛𝑛 + 𝑐𝑐1 + 𝑐𝑐2 + 𝑐𝑐4 + − − + 𝑐𝑐8 n
2 2 2 2 2 2
− 𝑐𝑐2 + 𝑐𝑐4 + 𝑐𝑐5 + 𝑐𝑐8
2 Quadratic
𝑇𝑇 𝑛𝑛 = 𝑎𝑎𝑛𝑛 + 𝑏𝑏𝑏𝑏 + 𝑐𝑐
function of n
Growth Function
Asymptotic notation
The order of growth of the running time of an algorithm
gives a simple characterization of the algorithm's
efficiency.
For
input sizes large enough, we make only the order of
growth of the running time relevant, so we study the
asymptotic efficiency of algorithms.
Asymptotic notation
Θ notation
Θ(g(n)) = {f(n) : there exist positive constants c1, c2, and n0 such
that 0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0}.
We usually write f(n)= Θ(g(n)) to express the same notation
We say that g(n) is an asymptotically tight bound for f(n)
Ο notation
O(g(n)) = {f(n): there exist positive constants c and n0 such that
0≤ f(n) ≤ cg(n) for all n ≥ n0}
We write f(n)= Ο(g(n)) to indicate that a function f(n) is a member of
the set Ο(g(n))
We use Ο-notation when we have an asymptotic upper bound
Asymptotic notation (Cont..)
Ω notation
Ω(g(n)) = {f(n): there exist positive constants c and n0 such that
0 ≤ cg(n) ≤ f(n) for all n ≥ n0}.
We write f(n)= Ω (g(n)) to indicate that a function f(n) is a member of
the set Ω (g(n))
Ω-notation provides an asymptotic lower bound
Thanks for your Attention
Q&A