Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Luebke 1 9/11/2015 CS 332: Algorithms Introduction Proof By Induction.

Similar presentations


Presentation on theme: "David Luebke 1 9/11/2015 CS 332: Algorithms Introduction Proof By Induction."— Presentation transcript:

1 David Luebke 1 9/11/2015 CS 332: Algorithms Introduction Proof By Induction

2 David Luebke 2 9/11/2015 The Course l Purpose: a rigorous introduction to the design and analysis of algorithms n Not a lab or programming course n Not a math course, either l Textbook: Introduction to Algorithms, Cormen, Leiserson, and Rivest (CLR) n The “Big White Book” n An excellent reference you should own

3 David Luebke 3 9/11/2015 The Course l Instructor: David Luebke n luebke@cs.virginia.edu n Office: Olsson 219 l TA: Emily Evans l Grader: Wei Lin Zhong

4 David Luebke 4 9/11/2015 The Course l Grading policy (overrides web page): n Homework: 40% n Midterm: 20% n Final: 35% n Participation: 5%

5 David Luebke 5 9/11/2015 The Course l Prerequisites: n CS 302 w/ grade of C- or better n CS 216 w/ grade of C- or better n These are strictly enforced! l Who’s not registered? Write down: n Your name, year, and major (inc. Echols/Rodman) n Any special reason why you should be let into the course instead of others

6 David Luebke 6 9/11/2015 The Course l Format n Two lectures/week n Homework every week u Problem sets u Very occasional programming assignments n Two tests (tentative)

7 David Luebke 7 9/11/2015 Review: Induction l Suppose n S(k) is true for fixed constant k u Often k = 0 n S(n)  S(n+1) for all n >= k l Then S(n) is true for all n >= k

8 David Luebke 8 9/11/2015 Proof By Induction l Claim:S(n) is true for all n >= k l Basis: n Show formula is true when n = k l Inductive hypothesis: n Assume formula is true for an arbitrary n l Step: n Show that formula is then true for n+1

9 David Luebke 9 9/11/2015 Induction Example: Gaussian Closed Form l Prove 1 + 2 + 3 + … + n = n(n+1) / 2 n Basis: u If n = 0, then 0 = 0(0+1) / 2 n Inductive hypothesis: u Assume 1 + 2 + 3 + … + n = n(n+1) / 2 n Step (show true for n+1): 1 + 2 + … + n + n+1 = (1 + 2 + …+ n) + (n+1) = n(n+1)/2 + n+1 = [n(n+1) + 2(n+1)]/2 = (n+1)(n+2)/2 = (n+1)(n+1 + 1) / 2

10 David Luebke 10 9/11/2015 Induction Example: Geometric Closed Form l Prove a 0 + a 1 + … + a n = (a n+1 - 1)/(a - 1) for all a != 1 n Basis: show that a 0 = (a 0+1 - 1)/(a - 1) a 0 = 1 = (a 1 - 1)/(a - 1) n Inductive hypothesis: u Assume a 0 + a 1 + … + a n = (a n+1 - 1)/(a - 1) n Step (show true for n+1): a 0 + a 1 + … + a n+1 = a 0 + a 1 + … + a n + a n+1 = (a n+1 - 1)/(a - 1) + a n+1 = (a n+1+1 - 1)/(a - 1)

11 David Luebke 11 9/11/2015 Induction l We’ve been using weak induction l Strong induction also holds n Basis: show S(0) n Hypothesis: assume S(k) holds for arbitrary k <= n n Step: Show S(n+1) follows

12 David Luebke 12 9/11/2015 Induction l Another variation: n Basis: show S(0), S(1) n Hypothesis: assume S(n) and S(n+1) are true n Step: show S(n+2) follows l Convenient to prove that the i th Fibonacci number F i is given by:

13 David Luebke 13 9/11/2015 Inductive Proof? l Claim: n All pens are black l Basis: n Suppose the number of pens is 0, trivially all the pens are black l Hypothesis: n Assume if there are n pens, they are all black

14 David Luebke 14 9/11/2015 Inductive Proof? l Step: n Given n+1 pens, remove one pen, the remaining n pens are black by the inductive hypothesis u Call this set of n pens T 1 n Replace the first pen and remove another, the remaining n pens are black by inductive hypothesis u Call this set of n pens T 2 n The union of T 1 and T 2 is the original set of n+1 pens. Both subsets are black, so entire set is black. l What is wrong here?

15 David Luebke 15 9/11/2015 Up Next l In this course, we care most about asymptotic performance n How does the algorithm behave as the problem size gets very large? u Running time u Memory/storage requirements u Bandwidth/power requirements/logic gates/etc. n Coming up: u Asymptotic performance of two search algorithms, u A formal introduction to asymptotic notation u Solving recurrences


Download ppt "David Luebke 1 9/11/2015 CS 332: Algorithms Introduction Proof By Induction."

Similar presentations


Ads by Google