=============================================================== Lect 15 - November 14, 2008 - ECS 20 - Fall 2008 - Phil Rogaway =============================================================== Today: o Induction, recursion and recurrence relations, cont. (special Friday 50-minute in-discussion-section lecture) -------------------------- 1. Induction and recursion -------------------------- EXAMPLE 1. Sam's Dept Store sells enveloped in packages of 5 and 12. Prove that, for any n\ge 44, the store can sell you exactly n envelopes. [GP, p.147] Try it: 44 = 2(12) + 4(5) 45 = 9(5) 46 = 3(12) + 2(5) ?...? SUPPOSE: it is possible to buy k envelopes for some k\ge44. SHOW: it is possible to buy k+1 envelopes If purchasing at least seven packets of 5, trade them for three packets of 12: 7(5) -> 3(12) 35 36 If <7 packets of 5, ie <=6 fewer packets of 5, so at most 30 of the envelopes are in packets of 5; so there are >= 44-30 = 14 envelopes being bought in packets of 12, so >= 2 two packets of twelve. So take two of the packets of 12 and trade them for 5 packets of 5: 2(12) -> 5(5) 24 25 ----------------------------------- Principle of mathematical induction ----------------------------------- To prove a proposition P(n) for all integers n\ge n_0: 1) Prove P(n_0) (Basis) 2) Prove that P(k) --> P(k+1) for all k > n_0 (inductive step) (Inductive hypothesis) (initially make n_0=1) And that's as far as we got today!! Sometimes convenient to strengthen this: ----------------------------------- Principle of mathematical induction ----------------------------------- To prove a proposition P(n) for all integers n\ge n_0: 1) Prove P(n_0) (Basis) 2) Prove that (P(n_0) and P(k+1) and ... and P(k)) --> P(k+1) for all k > n_0 (inductive step) (Inductive hypothesis) EXAMPLE 2: Show that you can tile any "punctured" n x n grid with "trominos" # ## (may be rotated) Illustrate and prove, dividing board in into 2^k x 2^k to prove 2^{k+1} x 2^{k+1}, puncturing three near-center center points (for the three 2^k} x 2^k pieces that lacking the puncture), and recurse. EXAMPLE 3: Prove that the sum of the the odd integers 2 .. 2n-1 is n^2 1 + 3 + ... + (2n-1) = n^2. Basis: n=1, check Inductive step: 4*2^{2k}-1 = (2^{2k} - 1) + (2^{2k} - 1) + (2^{2k} - 1) + (2^{2k} - 1) + 3 3 divides 3 divides 3 divides 3 divides 3 divides suppose 1 + 3 + ... (2n-3) = (n-1)^2 + 2n-1 = (n-1)^2 + 2n-1 = n^2 - 2n + 1 + 2n - 1 = 1 = n^2 (For HW p. 158, p. 30?) EXAMPLE 4: Cake cutting. See http://www.cs.berkeley.edu/~daw/teaching/cs70-s05/Notes/cakecutting.pdf for a nice writeup n people. want to divide equally. n=2: known case. n>=3: 1. Persons 1 .. n-1 people divide the cake into n-1 pieces (using a recursive call to this procedure). 2. Persons 1 .. n-1 divide their piece into n equal shares. 3. Person n takes the largest piece among the pieces held by each person 1..n-1. 4. Persons 1..n-1 keep their remaining n-1 pieces for themselves Remaining n-1 people keep their remaining portion of cake. Running time: T_n = T_{n-1} + n T_n = Theta(n!) Yuck!