Presentation is loading. Please wait.

Presentation is loading. Please wait.

Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1.

Similar presentations


Presentation on theme: "Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1."— Presentation transcript:

1 snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1

2 Outline Prereqs, Learning Goals, and Quiz Notes Problems and Discussion –Single-Elimination Tournaments –Binary Trees A First Pattern for Induction Induction on Numbers Next Lecture Notes 2

3 Quiz Notes You’re faced with a problem like “How many teams can play in a 100 round tournament?” or “How many teams can play in an n-round tournament?” You don’t know the answer. What can you do? Strategies: Try to clearly define terms (What’s a tournament? What’s a round?) Try a smaller number. 100 is hard, what about 1 or 2? Write the problem (or a small version) out as a story and figure out which parts of the story matter. 3

4 Learning Goals: Pre-Class By the start of class, you should be able to: –Convert sequences to and from explicit formulas that describe the sequence. –Convert sums to and from summation/“sigma” notation. –Convert products to and from product/“pi” notation. –Manipulate formulas in summation/product notation by adjusting their bounds, merging or splitting summations/products, and factoring out values. 4

5 Learning Goals: In-Class By the end of this unit, you should be able to: –Establish properties of self-referential structures using inductive proofs that naturally build on those self-references. 5

6 Where We Are in The Big Stories Theory How do we model computational systems? Now: Developing a new proof technique that’s perfect for algorithms involving (111 people) loops or (110 people) recursion... which is almost all interesting algorithms! Hardware How do we build devices to compute? Now: Taking a break in lecture. In lab, continuing to build toward the complete, working computer! 6

7 Outline Prereqs, Learning Goals, and Quiz Notes Problems and Discussion –Single-Elimination Tournaments –Binary Trees A First Pattern for Induction Induction on Numbers Next Lecture Notes 7

8 Single-Elimination Tournaments In each round teams play in pairs. Losing teams are eliminated. The tournament ends when only one team remains. 8

9 Single-Elimination Tournament Problem What’s the maximum number of teams in a 1-round single-elimination tournament? a.0 teams b.1 team c.2 teams d.3 teams e.None of these 9

10 Single-Elimination Tournament Problem What’s the maximum number of teams in a 2-round single-elimination tournament? a.0 teams b.1 team c.2 teams d.3 teams e.None of these 10

11 Single-Elimination Tournament Problem What’s the maximum number of teams in an n-round single-elimination tournament? a.n teams b.2n teams c.n 2 teams d.2 n teams e.None of these 11

12 Tournament Step-by-Step Problem 2: Prove your result for... n = 1 n = 2 n = 3 n = 4... 12 n = 0?

13 Tournament Logic So, if p teams can play in an n-round tournament, then 2p teams can play in an n+1-round tournament. If we want to prove this statement, which of the following techniques might we use? a.Antecedent assumption b.Witness proof c.WLOG d.Proof by cases e.None of these 13

14 Tournaments Built from Tournaments The key insight is the same way hockey (and many other sports) get from an “east half” and “west half” tournament to a whole tournament: 14 One extra round: east winner vs. west winner

15 Tournaments Built from Tournaments A tournament is either one game (1-round tournament), or it’s two slightly shorter tournaments combined by having the champions play against each other. 15 One extra round: east winner vs. west winner

16 Tournament Proof Theorem: 2 n teams can play in an n-round tournament. Proof: Only two (2 1 ) teams can play in a 1-round tournament. We work up to any other size by showing: if 2 k teams can play in a k-round tournament, then 2 k+1 teams can play in an k+1-round tournament. Assume the antecedent: 2 k teams can play in a k-round tournament. A k+1-round tournament is two k-round tournaments (“eastern and western conferences” or the like) where the winners play each other for the overall championship. Each of the k-round tournaments has 2 k teams in it. So, the k+1-round tournament has: 2 k + 2 k = 2*2 k = 2 k+1 teams. QED 16

17 Tournament Step-by-Step Problem 2: Prove your result for... n = 12 teams n = 22*2 = 2 2 = 4 teams n = 32*4 = 2 3 = 8 teams n = 42*8 = 2 4 = 16 teams... 17

18 Outline Prereqs, Learning Goals, and Quiz Notes Problems and Discussion –Single-Elimination Tournaments –Binary Trees A First Pattern for Induction Induction on Numbers Next Lecture Notes 18

19 “Binary Trees” A “binary tree” is a root “node” and a collection of “child nodes” beneath the root. Each node is an object that has up to two children—a left child and a right child—each of which are themselves binary trees. 19 20 92 15 5 10 177 (They let us do some cool CS things... see CS110, 210, 211, 221.)

20 Binary Trees’ Height A binary tree’s “height” is the maximum number of steps it takes to get from the root down to a node with no children. This one’s height is: a.0 b.1 c.2 d.3 e.4 20 92 15 5 10 177 20 92 15 5 10 177

21 Binary Trees’ Height Problem 1: What’s the maximum number of nodes in a binary tree of height n? 21 20 92 15 5 10 177

22 Binary Trees’ Height Problem 2: Prove your result. 22 20 92 15 5 10 177

23 Binary Trees, Take Two Problem 1: Give an algorithm to determine the height of a binary tree. Problem 2: Prove that your algorithm is correct. 23 20 92 15 5 10 177

24 Outline Prereqs, Learning Goals, and Quiz Notes Problems and Discussion –Single-Elimination Tournaments –Binary Trees A First Pattern for Induction Induction on Numbers Next Lecture Notes 24

25 An Induction Proof Pattern Type of Problem: Prove some property of a structure that is naturally defined in terms of itself. Part 1: Insight. Induction doesn’t help you with this part. It is not a technique to figure out patterns, only to prove them. Part 2: Proof. Establish that the property holds for simple structures. Establish that it holds at each step of construction of a more complex structure. 25

26 Natural Numbers and Induction Can we prove things about the natural numbers using induction? Are they “self- referential”? Let’s try one... Problem: What is the sum of the natural numbers 0..n? 26

27 Partly Worked Problem: Sum of 0..n Partly Worked Problem: What is the sum of the natural numbers 0..n? Induction doesn’t help with insight... But spoilers do: n(n+1)/2. Now, how do we prove it? 27

28 Partly Worked Problem: Sum of 0..n Partly Worked Problem: Prove that the sum of the natural numbers 0..n is n(n+1)/2. Is this self-referential? If we knew the sum of the numbers 0..(n-1), would it tell us anything about the sum of the numbers 0..n? 28

29 Outline Prereqs, Learning Goals, and Quiz Notes Problems and Discussion –Single-Elimination Tournaments –Binary Trees A First Pattern for Induction Induction on Numbers Next Lecture Notes 29

30 Learning Goals: In-Class By the end of this unit, you should be able to: –Establish properties of self-referential structures using inductive proofs that naturally build on those self-references. Note: this learning goal is not yet looking for formal inductive proofs. Instead, we’re just exploring how we work with things that are defined in terms of themselves. 30

31 Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: –Given a theorem to prove stated in terms of its induction variable (i.e., usually, in terms of n), write out the skeleton of an inductive proof including: the base case(s) that need to be proven, the induction hypothesis, and the inductive step that needs to be proven. So, take what we did in this lecture and use the textbook readings to formalize your understanding. We will have much more practice on inductive proofs. 31

32 Next Lecture Prerequisites See the Mathematical Induction Textbook Sections at the bottom of the “Textbook and References” page.Mathematical Induction Textbook Sections 32


Download ppt "Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1."

Similar presentations


Ads by Google