11 views

Uploaded by Jagrut Kosti

save

- Section 5.3-10
- IT data structures
- [Walter G. Kelley, Allan C. Peterson] Difference e(BookSee.org)
- Merge Sort
- Linked List
- Recurrence Relation
- Recurrence Relations
- UNIT - V
- SSRN-id1773169
- CAB301_Levitin_Ch2.pdf
- hw1[1]
- week1_2_3_4_5_6_7_8_9_10_11
- S.Y. BSc. Comp Science
- 22 1489647800_16-03-2017.pdf
- Differential Privacy
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- The Unwinding: An Inner History of the New America
- Yes Please
- Sapiens: A Brief History of Humankind
- The Emperor of All Maladies: A Biography of Cancer
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grand Pursuit: The Story of Economic Genius
- This Changes Everything: Capitalism vs. The Climate
- The Prize: The Epic Quest for Oil, Money & Power
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- John Adams
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- Rise of ISIS: A Threat We Can't Ignore
- The New Confessions of an Economic Hit Man
- Team of Rivals: The Political Genius of Abraham Lincoln
- Angela's Ashes: A Memoir
- Steve Jobs
- How To Win Friends and Influence People
- Bad Feminist: Essays
- You Too Can Have a Body Like Mine: A Novel
- The Incarnations: A Novel
- The Light Between Oceans: A Novel
- Extremely Loud and Incredibly Close: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- The Silver Linings Playbook: A Novel
- Leaving Berlin: A Novel
- Bel Canto
- The Master
- A Man Called Ove: A Novel
- Brooklyn: A Novel
- The Flamethrowers: A Novel
- The Rosie Project: A Novel
- The Blazing World: A Novel
- We Are Not Ourselves: A Novel
- The First Bad Man: A Novel
- The Love Affairs of Nathaniel P.: A Novel
- Life of Pi
- The Perks of Being a Wallflower
- The Bonfire of the Vanities: A Novel
- Lovers at the Chameleon Club, Paris 1932: A Novel
- The Cider House Rules
- A Prayer for Owen Meany: A Novel
- My Sister's Keeper: A Novel
- The Wallcreeper
- The Art of Racing in the Rain: A Novel
- Wolf Hall: A Novel
- Beautiful Ruins: A Novel
- The Kitchen House: A Novel
- Interpreter of Maladies
- 10-6
- Proyecto Final-Matematicas Discretas
- Computational-Aeroacoustics-A-Wave-Number-Approach.pdf
- 差和分與微積分
- New EC3001 Maths
- Método de Bairstow.pdf
- Advmai Ws1718 i
- hw10
- Discrete Mathematics
- newton kantrowich.pdf
- Combinat or Is
- 10.1.1.298.8019 (1).pdf
- funciones de Bessel.pdf
- Cs 6402 Design and Analysis of Algorithms
- cssyll3.pdf
- itsyllabus2010sem5
- Exercises of Design & Analysis
- CHE306
- Artigo Palácio dos Espelhos
- 19-1
- 1. Questions & Answers on Discrete Time Signals and Systems
- 21 3 z Trnsfm n Difrnce Eqn
- ODEs_Modern_perspective_Ebook_2003
- Math HL syllabus only.pdf
- Gauss Legendre Ian
- Soluciones Series
- Signals, Spectra, Signal Processing ECE 401 (TIP Reviewer)
- Lyapunov Exponents
- l21
- Analysis Recursive Algorithm

You are on page 1of 18

CS 3110

Textbook readings:

Chapter 4

CS 3110 — Recurrence Relations

1/12

Overview What are recurrence relations? What is their relationship to algorithm design? Methods to solve them: Substitution (induction in disguise) Recursion trees Master Theorem CS 3110 — Recurrence Relations 2/12 .

What Are Recurrence Relations? A recurrence relation expresses the value of a function f for an argument n in terms of the values of f for arguments less than n. Examples: f (n) = 1 if n ≤ 1 2f (n/2) + n if n > 1 f (n) = 5 if n ≤ 10 f (n/10) + f (n − 1) + f (n/2) if n > 10 CS 3110 — Recurrence Relations 3/12 .

q + 1. r) 5 Merge(A. p. r) CS 3110 — Recurrence Relations 4/12 . p. p. r) 1 if r > p 2 then q ← ⌊ p+r ⌋ 2 3 Merge-Sort(A. q) 4 Merge-Sort(A. Example: (Merge-Sort) Merge-Sort(A.Recurrence Relations and Recursive Algorithms The running time of a recursive algorithm is easily expressed using a recurrence relation. q.

Recurrence Relations and Recursive Algorithms The running time of a recursive algorithm is easily expressed using a recurrence relation. p. q) 4 Merge-Sort(A. r) Running time: T (n) = O(1) if n ≤ 1 2T (n/2) + O(n) if n > 1 CS 3110 — Recurrence Relations 4/12 . Example: (Merge-Sort) Merge-Sort(A. q + 1. q. p. p. r) 5 Merge(A. r) 1 if r > p 2 then q ← ⌊ p+r ⌋ 2 3 Merge-Sort(A.

Recurrence Relations and Optimization Problems Given: Set T of n tasks t1 . K) = the minimal cost of assigning the tasks in T to the contractors in K. K \ {ki })) if T = ∅ CS 3110 — Recurrence Relations 5/12 . k2 . tn Set K of n contractors k1 . A recurrence relation: C = c(T. . . K) = 0 if T = ∅ min1≤i≤n (ci1 + c(T \ {t1 }. . t2 . . . kn Contractor ki charges cij dollars for performing task tj Assign one task to every contractor Goal: Minimize the total cost C. . . K) c(T. . c(T.

Solving Recurrence Relations Given two algorithms for the same problem. Running times: Algorithm 1: T1 (n) = 2T1 (n/2) + O(n lg n) Algorithm 2: T2 (n) = 3T2 (n/2) + O(n) Which one is faster? CS 3110 — Recurrence Relations 6/12 .

Solving Recurrence Relations Given two algorithms for the same problem.) CS 3110 — Recurrence Relations 6/12 . Running times: Algorithm 1: T1 (n) = 2T1 (n/2) + O(n lg n) Algorithm 2: T2 (n) = 3T2 (n/2) + O(n) Which one is faster? We need closed forms of T1 (n) and T2 (n). (Expressions for T1 (n) and T2 (n) that are not recurrence relations.

(Expressions for T1 (n) and T2 (n) that are not recurrence relations.) To “solve” a recurrence relation means to derive such a closed form from the recurrence relation. CS 3110 — Recurrence Relations 6/12 .Solving Recurrence Relations Given two algorithms for the same problem. Running times: Algorithm 1: T1 (n) = 2T1 (n/2) + O(n lg n) Algorithm 2: T2 (n) = 3T2 (n/2) + O(n) Which one is faster? We need closed forms of T1 (n) and T2 (n).

Methods for Solving Recurrence Relations Substitution method: Make a guess Verify the guess using induction Recursion trees: Visualize how the recurrence unfolds May lead to a guess to be veriﬁed using substitution If done carefully. may lead to an exact solution Master theorem: “Cook-book” solution to a common class of recurrence relations CS 3110 — Recurrence Relations 7/12 .

Substitution Method Three steps: 1. Verify the guess for all n ≤ n0 . Prove that the guess is correct assuming that it can be veriﬁed for all n less than some n0 . (inductive step) 3. Make a guess 2. (base case) CS 3110 — Recurrence Relations 8/12 .

Verify the guess for all n ≤ n0 . Prove that the guess is correct assuming that it can be veriﬁed for all n less than some n0 .Substitution Method Three steps: 1. Make a guess 2. (inductive step) 3. (base case) Why do we switch the two parts of the inductive proof? CS 3110 — Recurrence Relations 8/12 .

Make a guess 2. (base case) Why do we switch the two parts of the inductive proof? Our guess is vague. CS 3110 — Recurrence Relations 8/12 .Substitution Method Three steps: 1. Verify the guess for all n ≤ n0 . Prove that the guess is correct assuming that it can be veriﬁed for all n less than some n0 . (inductive step) 3.

Prove that the guess is correct assuming that it can be veriﬁed for all n less than some n0 . we do not care. The inductive step may work only for certain values of c. and we do not want to know. Make a guess 2. The base case usually works for any value of c. T (n) = O(n lg n)) We do not know c. Verify the guess for all n ≤ n0 .Substitution Method Three steps: 1. Example: T (n) ≤ cn lg n (that is. CS 3110 — Recurrence Relations 8/12 . (base case) Why do we switch the two parts of the inductive proof? Our guess is vague. (inductive step) 3.

black magic. Recursion trees help us to visualize how the recurrence unfolds. . prove loose upper and lower bounds and tighten them. .How To Make a Guess Experience. If everything fails. CS 3110 — Recurrence Relations 9/12 . inspiration. .

Recursion Trees T (n) = 3T (n/4) + n2 n2 Cost n2 n 2 4 n 2 4 n 2 4 3 16 n2 n 2 16 n 2 16 n 2 16 n 2 16 n 2 16 n 2 16 n 2 16 n 2 16 n 2 16 3 2 16 n2 T (1) T (1) T (1) O(nlog4 3 ) Cost of the tree = sum of the costs of the levels T (n) = Θ(n2 ) CS 3110 — Recurrence Relations 10/12 .

for some ǫ > 0. for some c < 1 and all n ≥ n0 . (ii) If f (n) = Θ(nlogb a ). then T (n) = Θ(f (n)).Master Theorem Theorem: (Master Theorem) Let a ≥ 1 and b > 1. (iii) If f (n) = Ω(nlogb a+ǫ ). CS 3110 — Recurrence Relations 11/12 . for some ǫ > 0. then T (n) = Θ(nlogb a lg n). then T (n) = Θ(nlogb a ). and let T (n) be given by the following recurrence: T (n) = aT (n/b) + f (n) (i) If f (n) = O(nlogb a−ǫ ). and af (n/b) ≤ cf (n). let f (n) be a function over the positive integers.

There are three methods to solve recurrence relations: Substitution method Recursion trees Master theorem CS 3110 — Recurrence Relations 12/12 . Recurrence relations are useful for expressing the running times of recursive algorithms and the costs of optimal solutions to optimization problems.Summary A recurrence relation expresses the value of a function f for an argument n in terms of the values of f for arguments less than n.

- Section 5.3-10Uploaded byMorpho23
- IT data structuresUploaded byromeofatima
- [Walter G. Kelley, Allan C. Peterson] Difference e(BookSee.org)Uploaded byAbdulRehmanKhilji
- Merge SortUploaded byGaurav Tolani
- Linked ListUploaded byNitin Kusgal
- Recurrence RelationUploaded byCarlon Baird
- Recurrence RelationsUploaded byseascis
- UNIT - VUploaded byJit Agg
- SSRN-id1773169Uploaded byBennett Woodward
- CAB301_Levitin_Ch2.pdfUploaded byArchie Rudy Su'a
- hw1[1]Uploaded byGobara Dhan
- week1_2_3_4_5_6_7_8_9_10_11Uploaded byRejik Ivin
- S.Y. BSc. Comp ScienceUploaded byvikrantnetawane
- 22 1489647800_16-03-2017.pdfUploaded byEditor IJRITCC
- Differential PrivacyUploaded byRafael Stern

- 10-6Uploaded byksr131
- Proyecto Final-Matematicas DiscretasUploaded byAletse Solano Hermida
- Computational-Aeroacoustics-A-Wave-Number-Approach.pdfUploaded byIdul Azharul Hoque
- 差和分與微積分Uploaded bySTM Works
- New EC3001 MathsUploaded byaidanwimpress
- Método de Bairstow.pdfUploaded byPaula Viviana PeRea Diaz
- Advmai Ws1718 iUploaded byMandar Priya Phatak
- hw10Uploaded byAcep Harista Budi
- Discrete MathematicsUploaded bySagar Watts
- newton kantrowich.pdfUploaded byabviaud
- Combinat or IsUploaded byAng Xi Xiang
- 10.1.1.298.8019 (1).pdfUploaded byAllister Hodge
- funciones de Bessel.pdfUploaded byEdgar R. Mondragón
- Cs 6402 Design and Analysis of AlgorithmsUploaded byvidhya_bineesh
- cssyll3.pdfUploaded bygujjar262069
- itsyllabus2010sem5Uploaded byJijo Mathew
- Exercises of Design & AnalysisUploaded byAndyTrinh
- CHE306Uploaded byAbiola Olawale
- Artigo Palácio dos EspelhosUploaded byJaguaraci Silva
- 19-1Uploaded byksr131
- 1. Questions & Answers on Discrete Time Signals and SystemsUploaded bykibrom atsbha
- 21 3 z Trnsfm n Difrnce EqnUploaded byDaniel Solh
- ODEs_Modern_perspective_Ebook_2003Uploaded byHanan Altous
- Math HL syllabus only.pdfUploaded byPrakash Philip
- Gauss Legendre IanUploaded byM Sefrian Verties
- Soluciones SeriesUploaded byMDC95
- Signals, Spectra, Signal Processing ECE 401 (TIP Reviewer)Uploaded byJames Lindo
- Lyapunov ExponentsUploaded byCindy Liza Esporlas
- l21Uploaded bytheresa.painter
- Analysis Recursive AlgorithmUploaded byMini Girlrock