1 / 54

Recurrences

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

harvey
Download Presentation

Recurrences

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recurrences Lecture 2 Asst. Prof. Dr. İlker Kocabaş

  2. Inductive Hypothesis

  3. 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)

  4. 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))

  5. 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

  6. geometricseries = 16/11

More Related