Quiz 3 Reminder and Midterm Results

Similar documents
Preparing for the CS 173 (A) Fall 2018 Midterm 1

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

INDUCTION AND RECURSION. Lecture 7 - Ch. 4

Binomial Coefficient Identities/Complements

Try the assignment f(1) = 2; f(2) = 1; f(3) = 4; f(4) = 3;.

Recursion: Introduction and Correctness

Recurrences COMP 215

Discrete Mathematics. Spring 2017

Math 10850, fall 2017, University of Notre Dame

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Warm-up Simple methods Linear recurrences. Solving recurrences. Misha Lavrov. ARML Practice 2/2/2014

Chapter 5.1: Induction

Math 31 Lesson Plan. Day 2: Sets; Binary Operations. Elizabeth Gillaspy. September 23, 2011

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Recitation 7: Existence Proofs and Mathematical Induction

1 Examples of Weak Induction

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17

After linear functions, the next simplest functions are polynomials. Examples are

Mathematical Induction

CS2223 Algorithms D Term 2009 Exam 3 Solutions

Math Lecture 4 Limit Laws

CS173 Lecture B, September 10, 2015

Mathematical Induction

CS 2110: INDUCTION DISCUSSION TOPICS

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Every subset of {1, 2,...,n 1} can be extended to a subset of {1, 2, 3,...,n} by either adding or not adding the element n.

Math 3000 Section 003 Intro to Abstract Math Homework 6

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 3

Fall 2017 Test II review problems

MATH10040: Numbers and Functions Homework 1: Solutions

CmSc 250 Intro to Algorithms. Mathematical Review. 1. Basic Algebra. (a + b) 2 = a 2 + 2ab + b 2 (a - b) 2 = a 2-2ab + b 2 a 2 - b 2 = (a + b)(a - b)

4 Linear Recurrence Relations & the Fibonacci Sequence

Algebra 1: Hutschenreuter Chapter 10 Notes Adding and Subtracting Polynomials

What is proof? Lesson 1

CSC236 Week 4. Larry Zhang

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction. Linda Shapiro Spring 2016

Lecture 3. Big-O notation, more recurrences!!

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

Welcome to Math Video Lessons. Stanley Ocken. Department of Mathematics The City College of New York Fall 2013

Polynomial and Synthetic Division

MATH 2200 Final LC Review

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

Mathematical Fundamentals

Divide and Conquer Algorithms

CS173 Lecture B, November 3, 2015

Sequences of Real Numbers

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Lesson 3: Advanced Factoring Strategies for Quadratic Expressions

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

CS 4349 Lecture August 30th, 2017

Basics of Proofs. 1 The Basics. 2 Proof Strategies. 2.1 Understand What s Going On

McGill University Faculty of Science. Solutions to Practice Final Examination Math 240 Discrete Structures 1. Time: 3 hours Marked out of 60

Math Circle: Recursion and Induction

12 Sequences and Recurrences

Announcements. Read Section 2.1 (Sets), 2.2 (Set Operations) and 5.1 (Mathematical Induction) Existence Proofs. Non-constructive

Math Lecture 18 Notes

Ex. Here's another one. We want to prove that the sum of the cubes of the first n natural numbers is. n = n 2 (n+1) 2 /4.

A SUMMARY OF RECURSION SOLVING TECHNIQUES

F 2k 1 = F 2n. for all positive integers n.

Mathematical Induction

CS 340: Discrete Structures for Engineers

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Notes on induction proofs and recursive definitions

2.3 Differentiation Formulas. Copyright Cengage Learning. All rights reserved.

Section 4.2: Mathematical Induction 1

MATHEMATICAL INDUCTION

Learning Packet. Lesson 5b Solving Quadratic Equations THIS BOX FOR INSTRUCTOR GRADING USE ONLY

Lesson 8: Graphs of Simple Non Linear Functions

Divide and Conquer Algorithms

Solving Recurrence Relations 1. Guess and Math Induction Example: Find the solution for a n = 2a n 1 + 1, a 0 = 0 We can try finding each a n : a 0 =

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

3 Finite continued fractions

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Divide & Conquer. CS 320, Fall Dr. Geri Georg, Instructor CS320 Div&Conq 1

Any Wizard of Oz fans? Discrete Math Basics. Outline. Sets. Set Operations. Sets. Dorothy: How does one get to the Emerald City?

Some Review Problems for Exam 1: Solutions

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

COM S 330 Lecture Notes Week of Feb 9 13

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

Main topics for the First Midterm

Generating Functions

Lesson 2-6: Graphs of Absolute Value Equations

Basic Proof Examples

Chapter 4 Divide-and-Conquer

BMT 2016 Orthogonal Polynomials 12 March Welcome to the power round! This year s topic is the theory of orthogonal polynomials.

Main topics for the First Midterm Exam

Design and Analysis of Algorithms

MULTIPLYING TRINOMIALS

Algorithms Test 1. Question 1. (10 points) for (i = 1; i <= n; i++) { j = 1; while (j < n) {

Midterm 3 Review. Terms. Formulas and Rules to Use. Math 1010, Fall 2011 Instructor: Marina Gresham. Odd Root ( n x where n is odd) Exponent

Transcription:

Quiz 3 Reminder and Midterm Results Reminder: Quiz 3 will be in the first 15 minutes of Monday s class. You can use any resources you have during the quiz. It covers all four sections of Unit 3. It has four questions, two of them will be choices. Analysis for choice questions are optional, and can get partial credit if the choice is wrong. Midterm has been graded. Average mark is much higher than that of quizzes. Great! Midterm papers and your notes will be returned after class. You can reuse the note for the final. Gradesource report on Midterm will be available after discussion session. 1

CSE 21 Mathematics for Algorithm and System Analysis Unit 3: Decision Trees and Recursion Section 4: Inductive Proofs and Recursive Equations 2

Review : Recursive Solution We have a recursive solution to the problem (proof, algorithm, data structure, etc.) if the following two conditions hold. 1. The set of simplest problems can be dealt with (proved, calculated, sorted, etc.). 2. The solution to any other problem can be built from solutions to simpler problems, and this process eventually leads back to the original problem. Example: recursive solution to binomial coefficients C(0, 0) = 1, C(0, k)=0 for k 0 C(n, k) = C(n 1, k 1) + C(n 1, k) for n > 0 3

Learning Outcomes By the end of this lesson, you should be able to Use induction, or inductive proof, to prove statements. Verify/prove a solution to a recursion. It might be tested in examinations. Derive solutions for two types of recursions. a n =ba n-1 +c a n =ba n-1 +ca n-2 4

Why do we need to learn them? Induction is a commonly used way to prove statements for all natural numbers, including many recursions. Recursion is one of the central ideas of computer science. We will show some recursions have direct solutions. 5

Induction Suppose A(n) is an assertion that depends on n. We use induction to prove that A(n) is true when we show that It is true for the smallest value of n and If it is true for everything less than n, then it is true for n. 6

Induction Suppose A(n) is an assertion that depends on n. We use induction to prove that A(n) is true when we show that It is true for the smallest value of n and If it is true for everything less than n, then it is true for n. 7

Induction and Recursion Commonalities between induction and recursion Both need something to get started; In both, each new thing depends on similar previous things. Differences between induction and recursion A recursion describes how to calculate a value from previously calculated values. An induction verifies whether the above description/statement is correct. 8

Theorem 6: Induction Let A(m) be an assertion, the nature of which is dependent on the integer m. Suppose that n 0 n 1, if we have proved the two statements: (a) A(n) is true for n 0 n n 1 and (b) If n > n 1 and A(k) is true for all k such that n 0 k n-1, then A(n) is true. Then A(m) is true for all m n 0. Proof by contradiction 9

Theorem 6: Weak Induction Let A(m) be an assertion, the nature of which is dependent on the integer m. If we have proved the two statements: (a) A(n 0 ) is true and (b) If n > n 0 and A(n-1) is true, then A(n) is true. Then A(m) is true for all m n 0. It is a special case of the first one, called weak induction because its statements are easier to check. The first one is called strong induction. 10

Definition 5 : Induction hypothesis In statement (a), A(n 0 ),..., A(n 1 ) are called the base cases or simplest cases. In statement (b), A(k) is true for all k such that n 0 k n-1 is called the induction assumption or induction hypothesis. proving the induction hypothesis implies A(n) is called the inductive step. 11

Example 24: Every integer is a product of primes A positive integer n > 1 is called a prime if its only divisors are 1 and n, e.g.,: 2, 3, 5, 7. If a number is not a prime, such as 12, it can be written as a product of primes (12 = 2 2 3). A prime p is a product of one prime, itself. Question: how to prove every integer n 2 is a product of primes? 12

Solution to Example 24 Base cases: n 0 =n 1 =2, A(n 0 ) is true. Induction hypothesis: suppose that for some n > 2, A(k) is true for all k such that n 0 k n-1. Inductive step: check A(n) based on the hypothesis If n is a prime, then it is a product of primes (itself). Otherwise, n = st where 1<s<n and 1<t<n. By the induction hypothesis, s and t are each a product of primes, hence n = st is a product of primes. 13

Example 25 : Sum of first n integers Formula for the sum of the first n integers S(n) = 1 + 2 +... + n. Prove S(n)=n(n+1)/2 using weak induction Base cases: n 0 =1, S(1)=(1 2)/2=1, so A(n 0 ) is true. Induction hypothesis: n > 1 and A(n-1) is true. Inductive step: S(n) = 1 + 2 +... + n = (1 + 2 +... + (n-1))+n = S(n-1)+n = (n-1)((n-1)+1)/2+n = n(n+1)/2 14

Terms for Recursion Recursion, or recursive equation, or recurrence relation: the equation that arises in the inductive proof and tells how to compute the value for n based on the value(s) for smaller number(s). e.g., S(n) = S(n-1) + n (for n > 1) initial condition(s): the value(s) for smallest number(s). It is the information on how to get started. e.g., S(1)=1 solution to the recursion: the equation on how to compute the value for n without having to compute the values for any smaller number(s). e.g., S(n) = n(n+1)/2 Differentiate this from recursive solution to a problem which is about how to solve the problem using recursion. 15

Theorem 7 : Verifying the solution to a recursion We often use the same induction pattern to prove a formula for the solution to a recursion is correct. Theorem 7: Suppose we have initial conditions that give a n for n 0 n n 1 and a recursion that allows us to compute a n when n > n 1. To verify that a n = f(n), it suffices to do two things: Step 1. Verify that f satisfies the initial conditions. Step 2. Verify that f satisfies the recursion. 16

Example 26 : Proving a formula for the solution to a recursion Let S(n) be the sum of the first n integers. The initial condition S(1) = 1 and the recursion S(n) = S(n-1) + n allow us to compute S(n) for all n 1. Prove f(n) = n(n+1)/2= S(n). Step 1: f(1)=1 (1+1)/2=1=S(1) Step 2: for n > 1, S(n)=n + S(n 1) = n + f(n 1) = n + n(n 1)/2 = n(n + 1)/2 = f(n) 17

Example 26 : Proving a formula for the solution to a recursion(2) Initial conditions: a 0 = 2, a 1 = 7 Recursion: a n = 3a n 1 2a n 2 when n > 1 Prove that a n = 5 2 n 3 for n 0. Step 1: f(0)= 5 2 0 3 =2, f(1)= 5 2 1 3 = 7 Step 2: 3 f(n 1) 2 f(n 2) =3 (5 2 n 1 3)-2 (5 2 n 2 3) = (3 5 2 2 5)2 n 2 3 = 5 2 n 3 = f(n) 18

How to get solutions to recursions? Some solutions are easy to guess Let r k = r k 1 /k for k 1, with r 0 = 1. Its first few terms are 1, 1, 1/2, 1/6, 1/24. It looks like r k = ( 1) k /k! is a solution. Some solutions are hard to guess b n = b 1 b n 1 + b 2 b n 2 + + b n 1 b 1 for n 2, with b 1 = 1. Some recursions do not have solutions partitions number of an n-set having exactly k blocks: S(n, k) = S(n 1, k 1) 1 + k S(n 1, k) Solutions to two types of recursion can be easily derived a n =ba n-1 +c a n =ba n-1 +ca n-2 Generally, it is usually easy to verify a solution to a recursion, but hard to find the solution on our own. 19

Theorem 8 : Solutions to Recursion a n = ba n 1 +c Let a 0, a 1,..., a n,... be a sequence of numbers. Suppose there are constants b and c such that b is not 0 or 1 and a n = ba n 1 +c for n 1. Then a n = Ab n + K where K = c/(1 b), and A = a 0 K = a 0 c/(1 b). It can be proved using the steps in Theorem 7: Initial Condition: Recursion: 20

Solutions to Some Recursions Let t k = 2t k 1 + 1 for k > 0, t 0 = 0. Compute its solution. K = c/(1 b) = 1/(1 2)= 1 A = a 0 K = 0 ( 1) = 1. So the solution is t k = 2 k 1. 21

Example 28 : I forgot the formulas for A and K Let a 1 = 3 and a n = 4a n 1 7 for n > 1. Compute its solution. Tricky part: We cannot use A = a 0 K directly because we do not know a 0. Since solution should be a n = A4 n + K a 1 = 3 = A4 1 + K a 2 = 4 3 7= A4 2 + K Solve the above two equations to get values of A and K. Solution: a n = 4 n /6+ 7/3. If you forgot formula for b, just add one more equation based on a 3 and solve the equations. 22

Theorem 9 : Solutions to Recursion a n = ba n 1 +ca n 2 Let a 0, a 1,..., a n,... be a sequence of numbers. Suppose there are constants b and c such that a n = ba n 1 +ca n 2 for n 2. Let r 1 and r 2 be the roots of the polynomial x 2 bx c. n n If r 1 r 2, then n 1 2 for n 0, where K 1 and K 2 are solutions to the equations K 1 + K 2 = a 0 and r 1 K 1 + r 2 K 2 = a 1. n n If r 1 = r 2, then an = K1 r1 + K 2nr2 for n 0, where K 1 and K 2 are solutions to the equations: K 1 = a 0 and r 1 K 1 + r 2 K 2 = r 1 K 1 + r 1 K 2 = a 1. Values of r 1 and r 2 : a = K1 r + K r2 r, r 1 2 b ± = b 2 2 + 4c 23

Example 29 : Applying Theorem 9 Let a 0 = 2, a 1 = 7 and a n = 3a n 1 2a n 2 for n > 2. Compute its solution. We have b = 3 and c = 2. Solving equation x 2 3x+2 = 0, we can get r 1 = 2 and r 2 = 1. r 1 r 2, so solve equation K 1 + K 2 = 2 and 2K 1 + K 2 = 7. Result is K 1 = 5, K 2 = 3. Solution is a n = 5 2 n 3 1 n = 5 2 n 3. 24

Example 29 : Applying Theorem 9 (2) A recursion is a 0 = 0, a 1 = 1, and a n = 4a n 1 4a n 2 for n > 2. Compute its solution. We have b = 4 and c = 4. Solving equation x 2 4x+4 = 0, we get r 1 = r 2 = 2. r 1 = r 2, so solve equation K 1 = 0, 2K 1 +2K 2 = 1. Result is: K 1 = 0, K 2 = 1/2. Solution is a n = K 1 2 n + K 2 n2 n = (1/2)n2 n = n2 n-1. 25

Example 29 : Applying Theorem 9 for Fibonacci recursion The recursion is : F 0 = F 1 = 1 and F k = F k 1 + F k 2 when k 2. We have b = 1 and c = 1. Solve equation is x 2 x 1 = 0, we get 1+ 5 1 5. r 1 r 2, so solve K 1 + K 2 = 1 and r 1 K 1 + r 2 K 2 = 1. Result is r1 r2. K 1 = r 1, K 5 = and r 2 2 = 5 2 = 2 Solution is Fn = 1 5 1+ 2 5 n+ 1 1 5 1 2 5 n+ 1 26

Example 30 : A shifted index Let a 1 = 0, a 2 = 1 and a n = 5a n 1 6a n 2 for n 3. Compute its solution. Tricky part: it starts with a 1 instead of a 0, so the equations for K 1 and K 2 cannot be directly used. Because b = 5 and c = 6, solve equation x 2 5x 6 = 0. We get r 1 = 6 and r 2 = 1. So a n = K 1 6 n K 2 ( 1) n. Based on a 1 and a 2, we have a 1 =0=6K 1 K 2 and a 2 =1=6 2 K 1 + K 2. Solve the equations, we get K 1 = 1/42, K 2 = 1/7. Solution is a n = (1/42) 6 n (1/7) ( 1) n. 27

Homework and Pre-Reading Assignment Homework: Exercise 4.1, 4.4, 4.5, 4.9, 4.11, in page DT-50 to DT-52 Prepare for Quiz 3 on Monday For next class, please read Section 1 of Unit Basic Concepts in Graph Theory (GT-1 to GT-7). Try to understand definitions of Graph from examples. Try to understand Equivalence Relation and how to use it to get isomorphic graphs. 28