Lecture1 Intro
Lecture1 Intro
Course Overview
❑ Textbook and References
❑ Ellis Horowitz, and Sartaj Sahni, Fundamentals of Computer Algorithms,
Galgotia Publications (P) Ltd.
❑ Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein,
Introduction to Algorithms, Prentice-Hall of India Private Limited.
❑ Handouts that I will provide
❑ Grading Distribution
◼ Attendance – 10%
◼ Class Test / Quizz – 20%
◼ Mid Term Exam – 30%
◼ Final Exam – 40%
What is this Course About?
❑ Analyze the asymptotic performance of algorithms.
❑ Apply important algorithmic design paradigms and methods
including :
▪ Divide and Conquer
▪ Dynamic Programming
▪ Greedy Algorithms
▪ Backtracking
▪ And many more
Algorithm
Sequence of
Input computational Output
steps
Example of Algorithm: Sorting Problem
❑ Input: A sequence of n numbers: a1, a2 ,..., an
𝑇 𝑛 = 𝑐1𝑛 + 𝑐2 𝑛 − 1 + 𝑐4 𝑛 − 1 + 𝑐5 𝑛 − 1 + 𝑐8 𝑛 − 1
𝑇 𝑛 = 𝑐1 + 𝑐2 + 𝑐4 + 𝑐5 + 𝑐8 𝑛 − 𝑐2 + 𝑐4 + 𝑐5 + 𝑐8
𝑇 𝑛 = 𝑎𝑛 + 𝑏
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
𝑇 𝑛 = 𝑛2 + 𝑐1 + 𝑐2 + 𝑐4 + − − + 𝑐8 n
2 2 2 2 2 2
− 𝑐2 + 𝑐4 + 𝑐5 + 𝑐8
Quadratic
𝑇 𝑛 = 𝑎𝑛2 + 𝑏𝑛 + 𝑐
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