Transcript Problem 2
snick
snack
CPSC 121: Models of Computation
2010 Winter Term 2
Introduction to Induction
Steve Wolfman
1
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
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
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
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
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
Single-Elimination Tournaments
In each round teams play in pairs. Losing
teams are eliminated. The tournament
ends when only one team remains.
8
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
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
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. n2 teams
d. 2n teams
e. None of these
11
Tournament
Step-by-Step
Problem 2: Prove your result for...
n=1
n=2
n=3
n=4
...
n = 0?
12
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
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:
One extra round:
east winner vs. west winner
14
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.
One extra round:
east winner vs. west winner
15
Tournament Proof
Theorem: 2n teams can play in an n-round tournament.
Proof:
Only two (21) teams can play in a 1-round tournament.
We work up to any other size by showing:
if 2k teams can play in a k-round tournament, then
2k+1 teams can play in an k+1-round tournament.
Assume the antecedent: 2k 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 2k teams in it.
So, the k+1-round tournament has:
2k + 2k = 2*2k = 2k+1 teams.
QED
16
Tournament
Step-by-Step
Problem 2: Prove your result for...
n=1
n=2
n=3
n=4
...
2 teams
2*2 = 22 = 4 teams
2*4 = 23 = 8 teams
2*8 = 24 = 16 teams
17
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
“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.
10
5
2
20
9
7
15
17
19
(They let us do some cool CS things... see CS110, 210, 211, 221.)
10
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.
5
This one’s height is:
a. 0
2
b. 1
c. 2
7
d. 3
e. 4
5
20
2
9
15
7
17
10
20
9
15
17
20
10
Binary Trees’ Height
5
20
2
15
9
7
17
Problem 1: What’s the maximum number of
nodes in a binary tree of height n?
21
10
Binary Trees’ Height
5
20
2
9
15
7
17
Problem 2: Prove your result.
22
10
Binary Trees,
Take Two
5
20
2
9
15
7
17
Problem 1: Give an algorithm to determine
the height of a binary tree.
Problem 2: Prove that your algorithm is
correct.
23
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
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
Natural Numbers and Induction
Can we prove things about the natural
numbers using induction? Are they “selfreferential”?
Let’s try one...
Problem: What is the sum of the natural
numbers 0..n?
26
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
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
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
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
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.
31
We will have much more practice on inductive proofs.
Next Lecture Prerequisites
See the Mathematical Induction Textbook
Sections at the bottom of the “Textbook
and References” page.
32