Tutorial1 373
Tutorial1 373
Tutorial 1
Monday, Sep 20, 2021
1. If f (n) = O nlogb a− for some constant > 0, then T (n) = O nlogb a .
2. If f (n) = Θ nlogb a logk n for some constant k > 0, then T (n) = O nlogb a logk+1 n .
3. If f (n) = Ω nlogb a+ for some constant > 0 and f satisfies the regularity condition*, then
T (n) = O (f (n)).
(*Regularity condition: For some constant c < 1 and all sufficiently large n, a·f (n/b) 6 c·f (n).)
Note: There are recurrence relations which do not fall under any of these three cases (e.g. the
recurrence relation T (n) 6 T (n/5) + T (7n/10) + O(n) from QuickSelect where the smaller instances
√ √
are not of uniform size, or the recurrence relation T (n) 6 n · T ( n) + O(n) where a and b are
not constants). If you’re interested in how more general recurrences can be solved, there are some
excellent resources available online.1,2
1
We can obviously solve the problem in O(n) time by simply evaluating f (1), f (2), f (3), . . . , f (n).
Describe an O(log n) time algorithm.
[Hint: Try to quickly get an estimate of n, and then precisely pinpoint the exact value of n in the
range you estimated.]