Tutorial 2
Tutorial 2
CSCI3160 Tutorial2
[email protected] ZHANG Jian
Divide and Conquer
Cost satisfies T(n) = aT(n/b) + f(n). But how to know the cost for a
given n? We need to know the closed-form solution from the
recursive expression.
The Master Theorem (for equalities)
• T(n) = aT(n/b) + f(n), c =
• If f (n) = O() for some > 0 then T(n) = Θ()
• If f (n) = Θ() then T(n) = Θ( log n)
• If f (n) = () for some > 0 and if af (n/b) ≤ df (n) for some d < 1 and large
enough n then T(n) = Θ(f (n))
• where and are constants, f(n) is a function, and T(n) is defined on the
nonnegative integers by the recurrence
T(n)=T(n/2) + O(n)
Reference
• Cormen, Thomas H., et al. Introduction to algorithms. MIT
press, 2009.
• COMP3711H slides, HKUST
• Thank you