Week 3
Week 3
ALGORITHMS
Course Code : AR212
Credit Hours :3
Prerequisite : AR211
Instructor Information
[Pre-req. AR211
Textbook: Introduction to Algorithms, Thomas Cormen, Charls Leiserson & Ronald Rivest. 3rd Edition,
MIT Press, 2009.
Chapter 3
Growth of Functions
Dr. Aryaf Al-Adwan
Autonomous Systems Dept.
Design and Analysis of algorithms Course
Dr. Aryaf Al-Adwan
8
Outline
• Worst-Case Running Time: the longest time for any input size of n which
provides an upper bound on running time for any input.
• Best-Case Running Time: the shortest time for any input size of n which
provides lower bound on running time for any input
• Average-Case Behavior: the expected performance averaged over all
possible inputs
1. it is generally better than worst case behavior, but sometimes it’s
roughly as bad as worst case
2. difficult to compute
➔ n here means n0
1 < log n < √n < n < n log n < n2 < n3 < 2n < 3n < nn
Dr. Aryaf Al-Adwan 24
Dr. Aryaf Al-Adwan 25
Dr. Aryaf Al-Adwan 26
Big (O)
Definition:
Ω(g(n)) = { f (n) : there exist positive constants c and n 0 such that
f (n) ≥ cg(n) for all n ≥ n0 }
Solution:
c1= 1 n0=0
n2+10n ≥ n2
n=0 0 ≥ 0
n=1 11 ≥ 1
n=2 24 ≥ 4