Presentation is loading. Please wait.

Presentation is loading. Please wait.

(Proof By) Induction Recursion

Similar presentations


Presentation on theme: "(Proof By) Induction Recursion"— Presentation transcript:

1 (Proof By) Induction Recursion
Sections 8.4 and 8.7 (Proof By) Induction Recursion

2 Activity 1 A bit string of length 8 consists of a sequence of 8 characters limited to 1 and 0. It is sometimes written as: {0,1}8 How many length 8 bit strings contain exactly two sequences of exactly two consecutive 1s? For example, List them all.

3 Proof By Induction Arguably the most common form of proof used by computer scientists. Easy in theory. “Hard” in practice because there are two distinct steps to the proof (and for some reason you want to forget this).

4 Proof By Induction Two steps: Prove true for the “base case”
Prove true for the “inductive case” P(k) implies P(k+1) Assume that P(k) is true. Now prove that P(k+1) must also be true.

5 Activity 2 You can pay any amount of money x>=8 using only 3 cent and 5 cent coins. Prove this.

6 Activity 3 Create a formula that calculates the first n even integers.
Prove that your formula is correct.

7 Recursion In a recursive definition of a function, the value of the function is defined in terms of the output value of the function on smaller input values. Where did we use this idea on Friday?

8 Answer In proving that: We made note that P(n+1) = P(n) + (n+1)

9 Components of a recursive definition
A basis explicitly states that one or more specific elements are in the set. A recursive rule shows how to construct larger elements in the set from elements already known to be in the set. (There is often more than one recursive rule).

10 Components of a recursive definition of a set of things
A basis explicitly states that one or more specific elements are in the set. A recursive rule shows how to construct larger elements in the set from elements already known to be in the set. (There is often more than one recursive rule). An exclusion statement states that an element is in the set only if it is given in the basis or can be constructed by applying the recursive rules repeatedly to elements given in the basis.

11 Recursive Definitions vs. Recursive Algorithms
We probably should have read 8.9 in addition to, or even instead of, 8.7 I’m far more interested in you thinking about recursive algorithms.

12 What are some of the recursive algorithms you have seen?
Ones I could think of: Factorial Fibonacci Merge Sort

13 Some Code Examples


Download ppt "(Proof By) Induction Recursion"

Similar presentations


Ads by Google