540 likes | 666 Views
Recurrences. Lecture 2 Asst. Prof. Dr. İlker Kocabaş. Inductive Hypothesis. Subtleties. Consider the recurrence T(n) = 2T(n/2)+1 * Our guess O(n), T(n)≤ cn T(k) ≤ 2ck/2 + 1= ck+1 T(k) ≤ ck+1 Incorrect! T(n)=O(n) * Our guess O(n), T(n)≤ cn - b T(k) ≤ 2c[k/2-b] + 1= ck-2b+1
E N D
Recurrences Lecture 2 Asst. Prof. Dr. İlker Kocabaş
Inductive Hypothesis
Subtleties • Consider the recurrence T(n) = 2T(n/2)+1 • * Our guess O(n), T(n)≤ cn • T(k) ≤ 2ck/2 + 1= ck+1 • T(k) ≤ ck+1Incorrect! T(n)=O(n) • * Our guess O(n), T(n)≤ cn - b • T(k) ≤ 2c[k/2-b] + 1= ck-2b+1 • T(k) ≤ ck-b- [b-1], if b ≥ 1 • T(k) ≤ ck-b Socorrect! T(n)=O(n)
Changing Variables • Consider the recurrence T(n) = 2T(n)+lg n • * Rename m=lg n n=2m • T(2m) = 2T(2m)+m • T(2m) = 2T(2m/2)+m • * New recurrence, S(m)=T(2m) • S(m)=S(m/2)+m Solution! S(m)=O(m lg m) • * Solution for T(n) = S(m)=O(m lg m) • = O((lg n) lg( lg n))
Series & Term Bounds • * Geometric Series • for 0≤k≤n, xk= xn+1-1/x-1 • for 0≤k≤∞ and |x| < 1, xk= 1/1-x • * Harmonic Series • for 1≤k≤n, 1/k= ln n + O (1) • * Bounding the terms • for 1≤k≤∞, k/3k≤ 1/3(2/3)k
geometricseries = 16/11