web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · theorem: the...
TRANSCRIPT
![Page 1: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/1.jpg)
Mathematical InductionPart Two
![Page 2: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/2.jpg)
Problem Set Five
● Problem Set Four was due at 2:30PM today.
● Problem Set Five goes out today. It’s due next Friday at 2:30PM.● Play around with everything we’ve covered
so far, plus a healthy dose of induction and inductive problem-solving.
![Page 3: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/3.jpg)
Recap from Last Time
![Page 4: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/4.jpg)
Let P be some predicate. The principle of mathematical induction states that if
P(0) is true
and
∀k ∈ ℕ. (P(k) → P(k+1))
then
∀n ∈ ℕ. P(n)
If it starts true……and it stays
true…
…then it's always true.
![Page 5: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/5.jpg)
Theorem: The sum of the first n powers of two is 2n – 1.
Proof: Let P(n) be the statement “the sum of the first npowers of two is 2n – 1.” We will prove, by induction, thatP(n) is true for all n ∈ ℕ, from which the theorem follows.
For our base case, we need to show P(0) is true, meaningthat the sum of the first zero powers of two is 20 – 1. Sincethe sum of the first zero powers of two is zero and 20 – 1is zero as well, we see that P(0) is true.
For the inductive step, assume that for some arbitraryk ∈ ℕ that P(k) holds, meaning that
20 + 21 + … + 2k-1 = 2k – 1. (1)
We need to show that P(k + 1) holds, meaning that the sumof the first k + 1 powers of two is 2k+1 – 1. To see this,notice that
20 + 21 + … + 2k-1 + 2k = (20 + 21 + … + 2k-1) + 2k
= 2k – 1 + 2k (via (1))= 2(2k) – 1= 2k+1 – 1.
Therefore, P(k + 1) is true, completing the induction. ■
![Page 6: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/6.jpg)
Theorem: The sum of the first n powers of two is 2n – 1.
Proof: Let P(n) be the statement “the sum of the first npowers of two is 2n – 1.” We will prove, by induction, thatP(n) is true for all n ∈ ℕ, from which the theorem follows.
For our base case, we need to show P(0) is true, meaningthat the sum of the first zero powers of two is 20 – 1. Sincethe sum of the first zero powers of two is zero and 20 – 1is zero as well, we see that P(0) is true.
For the inductive step, assume that for some arbitraryk ∈ ℕ that P(k) holds, meaning that
20 + 21 + … + 2k-1 = 2k – 1. (1)
We need to show that P(k + 1) holds, meaning that the sumof the first k + 1 powers of two is 2k+1 – 1. To see this,notice that
20 + 21 + … + 2k-1 + 2k = (20 + 21 + … + 2k-1) + 2k
= 2k – 1 + 2k (via (1))= 2(2k) – 1= 2k+1 – 1.
Therefore, P(k + 1) is true, completing the induction. ■
![Page 7: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/7.jpg)
Theorem: The sum of the first n powers of two is 2n – 1.
Proof: Let P(n) be the statement “the sum of the first npowers of two is 2n – 1.” We will prove, by induction, thatP(n) is true for all n ∈ ℕ, from which the theorem follows.
For our base case, we need to show P(0) is true, meaningthat the sum of the first zero powers of two is 20 – 1. Sincethe sum of the first zero powers of two is zero and 20 – 1is zero as well, we see that P(0) is true.
For the inductive step, assume that for some arbitraryk ∈ ℕ that P(k) holds, meaning that
20 + 21 + … + 2k-1 = 2k – 1. (1)
We need to show that P(k + 1) holds, meaning that the sumof the first k + 1 powers of two is 2k+1 – 1. To see this,notice that
20 + 21 + … + 2k-1 + 2k = (20 + 21 + … + 2k-1) + 2k
= 2k – 1 + 2k (via (1))= 2(2k) – 1= 2k+1 – 1.
Therefore, P(k + 1) is true, completing the induction. ■
![Page 8: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/8.jpg)
Theorem: The sum of the first n powers of two is 2n – 1.
Proof: Let P(n) be the statement “the sum of the first npowers of two is 2n – 1.” We will prove, by induction, thatP(n) is true for all n ∈ ℕ, from which the theorem follows.
For our base case, we need to show P(0) is true, meaningthat the sum of the first zero powers of two is 20 – 1. Sincethe sum of the first zero powers of two is zero and 20 – 1is zero as well, we see that P(0) is true.
For the inductive step, assume that for some arbitraryk ∈ ℕ that P(k) holds, meaning that
20 + 21 + … + 2k-1 = 2k – 1. (1)
We need to show that P(k + 1) holds, meaning that the sumof the first k + 1 powers of two is 2k+1 – 1. To see this,notice that
20 + 21 + … + 2k-1 + 2k = (20 + 21 + … + 2k-1) + 2k
= 2k – 1 + 2k (via (1))= 2(2k) – 1= 2k+1 – 1.
Therefore, P(k + 1) is true, completing the induction. ■
![Page 9: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/9.jpg)
New Stuff!
![Page 10: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/10.jpg)
Induction in Practice
● Often, a proof by induction will not explicitly state P(n).
● Rather, the proof will describe P(n) implicitly and leave it to the reader to fill in the details.
● Provided that there is sufficient detail to determine● what P(n) is;● that P(0) is true; and that● whenever P(k) is true, P(k+1) is true,
the proof is usually valid. In this class, you could err on the side of safety by always defining it, but it’s not required.
![Page 11: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/11.jpg)
Theorem: The sum of the first n powers of two is 2n – 1.
Proof: By induction.
For our base case, we'll prove the theorem is true whenn = 0. The sum of the first zero powers of two is zero, and20 – 1 = 0, so the theorem is true in this case.
For the inductive step, assume the theorem holds whenn = k for some arbitrary k ∈ ℕ. Then we have
20 + 21 + … + 2k-1 + 2k = (20 + 21 + … + 2k-1) + 2k
= 2k – 1 + 2k
= 2(2k) – 1= 2k+1 – 1.
So the theorem is true when n = k+1, completing theinduction. ■
![Page 12: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/12.jpg)
A Fun Application:The Limits of Data Compression
![Page 13: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/13.jpg)
Bitstrings
● A bitstring is a finite sequence of 0s and 1s.
● Examples:● 11011100● 010101010101● 0000● ε (the empty string)
● There are 2n bitstrings of length n.
![Page 14: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/14.jpg)
Data Compression
● Inside a computer, all data are represented as sequences of 0s and 1s (bitstrings)
● To transfer data over a network (or on a flash drive, if you're still into that), it is useful to reduce the number of 0s and 1s before transferring it.
● Most real-world data can be compressed by exploiting redundancies.● Text repeats common patterns (“the”, “and”, etc.)● Bitmap images use similar colors throughout the image.
● Idea: Replace each bitstring with a shorter bitstring that contains all the original information.● This is called lossless data compression.
![Page 15: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/15.jpg)
101010101010101010101010101010
![Page 16: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/16.jpg)
101010101010101010101010101010
1111010
Compress
![Page 17: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/17.jpg)
101010101010101010101010101010
1111010
1111010
Compress
Transmit
![Page 18: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/18.jpg)
101010101010101010101010101010
1111010
1111010
101010101010101010101010101010
Compress
Decompress
Transmit
![Page 19: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/19.jpg)
Lossless Data Compression
● In order to losslessly compress data, we need two functions:
● A compression function C, and● A decompression function D.
● We need to have D(C(x)) = x.
● Otherwise, we can't uniquely encode or decode some bitstring.
● This means that D must be a left inverse of C, so (as you proved in PS3!) C must be injective.
![Page 20: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/20.jpg)
A Perfect Compression Function
● Ideally, the compressed version of a bitstring would always be shorter than the original bitstring.
● Question: Can we find a lossless compression algorithm that always compresses a string into a shorter string?
● To handle the issue of the empty string (which can't get any shorter), let's assume we only care about strings of length at least 10.
![Page 21: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/21.jpg)
A Counting Argument
● Let �n be the set of bitstrings of length n, and �<n be the set of bitstrings of length less than n.
● How many bitstrings of length n are there?
● Answer: 2n
● How many bitstrings of length less than n are there?
● Answer: 20 + 21 + … + 2n – 1 = 2n – 1
● By the pigeonhole principle, no function from �n to �<n can be injective – at least two elements must collide!
● Since a perfect compression function would have to be an injection from �n to �<n, there is no perfect compression function!
![Page 22: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/22.jpg)
Why this Result is Interesting
● Our result says that no matter how hard we try, it is impossible to compress every string into a shorter string.
● No matter how clever you are, you cannot write a lossless compression algorithm that always makes strings shorter.
● In practice, only highly redundant data can be compressed.
● The fields of information theory and Kolmogorov complexity explore the limits of compression; if you're interested, go explore!
![Page 23: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/23.jpg)
Variations on Induction: Starting Later
![Page 24: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/24.jpg)
Induction Starting at 0
● To prove that P(n) is true for all natural numbers greater than or equal to 0: ● Show that P(0) is true. ● Show that for any k ≥ 0, that
if P(k) is true, then P(k+1) is true.● Conclude P(n) holds for all natural numbers
greater than or equal to 0.
![Page 25: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/25.jpg)
Induction Starting at m
● To prove that P(n) is true for all natural numbers greater than or equal to m: ● Show that P(m) is true. ● Show that for any k ≥ m, that
if P(k) is true, then P(k+1) is true.● Conclude P(n) holds for all natural numbers
greater than or equal to m.
![Page 26: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/26.jpg)
Variations on Induction: Bigger Steps
![Page 27: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/27.jpg)
Subdividing a Square
![Page 28: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/28.jpg)
Subdividing a Square
![Page 29: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/29.jpg)
Subdividing a Square
![Page 30: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/30.jpg)
Subdividing a Square
![Page 31: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/31.jpg)
Subdividing a Square
![Page 32: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/32.jpg)
For what values of n can a square be subdivided into n squares?
![Page 33: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/33.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 34: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/34.jpg)
1
1 2 3 4 5 6 7 8 9 10 11 12
![Page 35: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/35.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 36: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/36.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
Each of the original corners needs to be covered by a corner of the new smaller squares.
![Page 37: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/37.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
Each of the original corners needs to be covered by a corner of the new smaller squares.
Number of corners = 4
Number of squares < 4
![Page 38: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/38.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
Each of the original corners needs to be covered by a corner of the new smaller squares.
By the pigeonhole principle, at least one smaller square needs to cover at least two of the original square’s corners.
![Page 39: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/39.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 40: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/40.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
1 2
34
![Page 41: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/41.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 42: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/42.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
Number of corners = 4
Number of squares = 5
![Page 43: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/43.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
Number of corners = 4
Number of squares = 5
At least one square cannot be covering any of the original corners
![Page 44: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/44.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 45: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/45.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
![Page 46: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/46.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
12
3
456
![Page 47: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/47.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
1
23
5 6
74
![Page 48: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/48.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
1
2
3
4 5 6 7
8
![Page 49: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/49.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
3
4
567
8 9
21
![Page 50: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/50.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
3
7
1 2
98
4
56
10
![Page 51: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/51.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
1
2
3
4 5 6 7
10 9
811
![Page 52: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/52.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
3
4
567
8
2
9 101112
1
![Page 53: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/53.jpg)
The Key Insight
![Page 54: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/54.jpg)
The Key Insight
![Page 55: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/55.jpg)
The Key Insight
![Page 56: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/56.jpg)
The Key Insight
![Page 57: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/57.jpg)
The Key Insight
![Page 58: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/58.jpg)
The Key Insight
![Page 59: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/59.jpg)
The Key Insight
![Page 60: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/60.jpg)
The Key Insight
![Page 61: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/61.jpg)
The Key Insight
![Page 62: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/62.jpg)
The Key Insight
![Page 63: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/63.jpg)
The Key Insight
● If we can subdivide a square into n squares, we can also subdivide it into n + 3 squares.
● Since we can subdivide a bigger square into 6, 7, and 8 squares, we can subdivide a square into n squares for any n ≥ 6:
● For multiples of three, start with 6 and keep adding three squares until n is reached.
● For numbers congruent to one modulo three, start with 7 and keep adding three squares until n is reached.
● For numbers congruent to two modulo three, start with 8 and keep adding three squares until n is reached.
![Page 64: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/64.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
![Page 65: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/65.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
![Page 66: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/66.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
![Page 67: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/67.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
![Page 68: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/68.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
![Page 69: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/69.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 70: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/70.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 71: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/71.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 72: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/72.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 73: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/73.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 74: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/74.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 75: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/75.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 76: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/76.jpg)
Theorem: For any n ≥ 6, it is possible to subdivide a square into nsmaller squares.
Proof: Let P(n) be the statement “a square can be subdivided inton smaller squares.” We will prove by induction that P(n) holdsfor all n ≥ 6, from which the theorem follows.
As our base cases, we prove P(6), P(7), and P(8), that a square can be subdivided into 6, 7, and 8 squares. This is shown here:
For the inductive step, assume that for some arbitrary k ≥ 6 that P(k) is true and that a square can be subdivided into k squares. We prove P(k+3), that a square can be subdivided into k+3 squares. To see this, start by obtaining (via the inductive hypothesis) a subdivision of a square into k squares. Then, choose any of the squares and split it into four equal squares. This removes one of the k squares and adds four more, so there will be a net total of k+3 squares. Thus P(k+3) holds, completing the induction. ■
1
4
2
3
56
1 2
356 7
4
12345678
![Page 77: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/77.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(6) P(8)P(7)
![Page 78: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/78.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)P(6)
P(8)P(7)
![Page 79: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/79.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)P(6)
P(8)P(7)
![Page 80: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/80.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3) P(9)
P(8)P(7)
![Page 81: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/81.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)P(8)P(7)
![Page 82: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/82.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)P(8)
P(7)
![Page 83: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/83.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)P(8)
P(7)
![Page 84: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/84.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)P(8)
P(10)
![Page 85: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/85.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)P(8) P(10)
![Page 86: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/86.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)
P(8)
P(10)
![Page 87: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/87.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)
P(8)
P(10)
![Page 88: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/88.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9)
P(11)
P(10)
![Page 89: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/89.jpg)
Why This Works
● This induction has three consecutive base cases and takes steps of size three.
● Thinking back to our “induction machine” analogy:
P(k) → P(k+3)
P(9) P(11)P(10)
![Page 90: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/90.jpg)
Generalizing Induction
● When doing a proof by induction,● feel free to use multiple base cases, and● feel free to take steps of sizes other than one.
● Just be careful to make sure you cover all the numbers you think that you're covering!● We won't require that you prove you've covered
everything, but it doesn't hurt to double-check!
![Page 91: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/91.jpg)
More on Square Subdivisions
● There are a ton of interesting questions that come up when trying to subdivide a rectangle or square into smaller squares.
● In fact, one of the major players in early graph theory (William Tutte) got his start playing around with these problems.
● Good starting resource: this Numberphile video on Squaring the Square.
![Page 92: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/92.jpg)
Complete Induction
![Page 93: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/93.jpg)
Guess what⁉
![Page 94: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/94.jpg)
It’s time for
Mathematicalesthenics!MathematiCalesthenics!
![Page 95: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/95.jpg)
It’s time for
Mathematicalesthenics!
![Page 96: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/96.jpg)
If you are the leftmost personin your row, stand up right now.
Everyone else: stand up as soon as the person to your left in your row stands up.
This is kindalike P(0).
This is kindalike P(0).
This is kinda like P(k) → P(k+1).
This is kinda like P(k) → P(k+1).
![Page 97: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/97.jpg)
Everyone, please be seated.
![Page 98: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/98.jpg)
Let’s do this again… with a twist!
![Page 99: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/99.jpg)
If you are the leftmost personin your row, stand up right now.
Everyone else: stand up as soon as everyone left of you in your row stands up.
This is kindalike P(0).
This is kindalike P(0).
What sort of sorcery is this?
What sort of sorcery is this?
![Page 100: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/100.jpg)
Please be seated.
You all did a great job!
![Page 101: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/101.jpg)
Let P be some predicate. The principle of complete induction states that if
P(0) is true
and
for any k ∈ ℕ, if P(0), P(1), …, and P(k) are true,then P(k+1) is true
then
∀n ∈ ℕ. P(n)
If it starts true……and it stays
true…
…then it's always true.
![Page 102: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/102.jpg)
Mathematical Induction
● You can write proofs using the principle of mathematical induction as follows: ● Define some predicate P(n) to prove by
induction on n.● Choose and prove a base case (probably, but
not always, P(0)).● Pick an arbitrary k ∈ ℕ and assume that
P(k) is true. ● Prove P(k+1).● Conclude that P(n) holds for all n ∈ ℕ.
![Page 103: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/103.jpg)
Complete Induction
● You can write proofs using the principle of complete induction as follows:● Define some predicate P(n) to prove by
induction on n.● Choose and prove a base case (probably, but
not always, P(0)).● Pick an arbitrary k ∈ ℕ and assume that
P(0), P(1), P(2), …, and P(k) are all true.● Prove P(k+1).● Conclude that P(n) holds for all n ∈ ℕ.
![Page 104: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/104.jpg)
A Motivating Example: Rat Mazes
![Page 105: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/105.jpg)
![Page 106: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/106.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
The maze should have these properties:
There is one entrance and one exit in the border.
Every spot in the maze is reachable from every other spot.
There is exactly one path from each spot in the maze to each other spot.
![Page 107: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/107.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
The maze should have these properties:
There is one entrance and one exit in the border.
Every spot in the maze is reachable from every other spot.
There is exactly one path from each spot in the maze to each other spot.
![Page 108: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/108.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● The maze should have these properties:● There is one entrance and
one exit in the border.● Every spot in the maze is
reachable from every other spot.
● There is exactly one path from each spot in the maze to each other spot.
![Page 109: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/109.jpg)
Question: If you have an n × m grid of pegs, how many slats do you need to make?
![Page 110: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/110.jpg)
A Special Type of Graph: Trees
![Page 111: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/111.jpg)
According to the above definition of trees, how many of thesegraphs are trees?
A tree is a connected, nonempty graph with no
simple cycles.
A tree is a connected, nonempty graph with no
simple cycles.
![Page 112: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/112.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
Trees have tons of nice properties:
They're maximally acyclic (adding any missing edge creates a simple cycle)
They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 113: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/113.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 114: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/114.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 115: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/115.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 116: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/116.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
● They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 117: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/117.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
● They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 118: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/118.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
● They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 119: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/119.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
● They're minimally connected (deleting any edge disconnects the graph)
Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 120: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/120.jpg)
Trees
● A tree is a connected, nonempty graph with no simple cycles.
● Trees have tons of nice properties:● They're maximally acyclic
(adding any missing edge creates a simple cycle)
● They're minimally connected (deleting any edge disconnects the graph)
● Proofs of these results are in the course reader if you're interested. They're also great exercises.
![Page 121: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/121.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 122: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/122.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 123: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/123.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 124: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/124.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 125: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/125.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 126: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/126.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 127: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/127.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 128: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/128.jpg)
Trees
● Theorem: If T is a tree with at least two nodes, then deleting any edge from T splits T into two nonempty trees T₁ and T₂.
● Proof: Left as an exercise to the reader. ☺
![Page 129: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/129.jpg)
Trees
● Theorem: If T is a tree with n ≥ 1 nodes, then T has exactly n-1 edges.
● Proof: Up next!
![Page 130: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/130.jpg)
Trees
● Theorem: If T is a tree with n ≥ 1 nodes, then T has exactly n-1 edges.
● Proof: Up next!
11
1
2
10
12
3
14 4
13
8
9
7
6
5
![Page 131: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/131.jpg)
Trees
● Theorem: If T is a tree with n ≥ 1 nodes, then T has exactly n-1 edges.
● Proof: Up next!
11
1
2
10
12
3
14 4
13
8
9
7
6
5
1
2
34
5
67
89
10
11
12
13
![Page 132: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/132.jpg)
Our Base Case
![Page 133: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/133.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
![Page 134: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/134.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
![Page 135: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/135.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
![Page 136: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/136.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
![Page 137: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/137.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
![Page 138: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/138.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
![Page 139: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/139.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
Suppose there are r nodes in the yellow tree.
Suppose there are r nodes in the yellow tree.
![Page 140: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/140.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
Suppose there are r nodes in the yellow tree.
Suppose there are r nodes in the yellow tree.
Then there are (k+1)-r nodes in the blue tree.
Then there are (k+1)-r nodes in the blue tree.
![Page 141: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/141.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
Suppose there are r nodes in the yellow tree.
Suppose there are r nodes in the yellow tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
Then there are (k+1)-r nodes in the blue tree.
Then there are (k+1)-r nodes in the blue tree.
![Page 142: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/142.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
Suppose there are r nodes in the yellow tree.
Suppose there are r nodes in the yellow tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
Then there are (k+1)-r nodes in the blue tree.
Then there are (k+1)-r nodes in the blue tree.
![Page 143: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/143.jpg)
Assume any tree with at most k nodes has one more node than
edge.
Assume any tree with at most k nodes has one more node than
edge.
Consider an arbitrary tree with k+1 nodes.
Consider an arbitrary tree with k+1 nodes.
Suppose there are r nodes in the yellow tree.
Suppose there are r nodes in the yellow tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
There are r-1 edges in the yellow tree and k-r edges in
the blue tree.
Adding in the initial edge we cut, there are
r-1 + k-r + 1 = k edges in the original tree.
Adding in the initial edge we cut, there are
r-1 + k-r + 1 = k edges in the original tree.
Then there are (k+1)-r nodes in the blue tree.
Then there are (k+1)-r nodes in the blue tree.
![Page 144: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/144.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 145: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/145.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 146: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/146.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 147: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/147.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 148: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/148.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 149: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/149.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 150: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/150.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 151: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/151.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 152: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/152.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 153: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/153.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 154: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/154.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 155: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/155.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 156: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/156.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 157: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/157.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 158: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/158.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 159: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/159.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 160: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/160.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 161: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/161.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 162: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/162.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 163: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/163.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 164: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/164.jpg)
Theorem: If T is a tree with n ≥ 1 nodes, then T has n-1 edges.
Proof: Let P(n) be the statement “any tree with n nodes has n-1 edges.”We will prove by induction that P(n) holds for all n ≥ 1, from whichthe theorem follows.
As a base case, we will prove P(1), that any tree with 1 node has 0 edges. Any such tree has single node, so it cannot have any edges.
Now, assume for some arbitrary k ≥ 1 that P(1), P(2), …, and P(k) are true, so any tree with between 1 and k nodes has one more node than edge. We will prove P(k+1), that any tree with k+1 nodes has k edges.
Consider any tree T with k+1 nodes. Since T has at least two nodes and is connected, it must contain at least one edge. Choose any edge in T and delete it. This splits T into two nonempty trees T₁ and T₂. Every edge in T is part of T₁, is part of T₂, or is the initial edge we deleted.
Let r be the number of nodes in T₁. Since every node in T belongs to either T₁ or T₂, we see that T₂ has (k+1)-r nodes. Additionally, since T₁ and T₂ are nonempty, neither T₁ nor T₂ contains all the nodes from T. Therefore, T₁ and T₂ each have between 1 and k nodes. We can then apply our inductive hypothesis to see that T₁ has r-1 edges and T₂ has k-r edges. Thus the total number of edges in T is 1 + (r-1) + (k-r) = k, as required. Therefore, P(k+1) is true, completing the induction. ■
![Page 165: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/165.jpg)
Induction vs. Complete Induction
Smaller problem
Bigger problem
![Page 166: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/166.jpg)
Induction vs. Complete Induction
Sum of first k powers of 2 = 2k – 1
Sum of first k+1 powers of 2 = 2k+1 – 1
Induction
![Page 167: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/167.jpg)
Induction vs. Complete Induction
Sum of first k powers of 2 = 2k – 1
Sum of first k+1 powers of 2 = 2k+1 – 1
Induction
Complete Induction
![Page 168: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/168.jpg)
Induction vs. Complete Induction
Size = k
Induction
Complete Induction
Size = k+1
Size = k+1Size = ??
![Page 169: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/169.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● Question: How many slats do you need to create?
Answer: mn – 2.
![Page 170: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/170.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● Question: How many slats do you need to create?
Answer: mn – 2.
![Page 171: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/171.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● Question: How many slats do you need to create?
Answer: mn – 2.
![Page 172: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/172.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● Question: How many slats do you need to create?
Answer: mn – 2.
This is a tree!
This is a tree!
![Page 173: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/173.jpg)
Rat Mazes
● Suppose you want to make a rat maze consisting of an n × m grid of pegs with slats between them.
● Question: How many slats do you need to create?
● Answer: mn – 2.
This is a tree!
This is a tree!
![Page 174: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/174.jpg)
For more on trees, take CS161 / 261 / 267!
![Page 175: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/175.jpg)
An Important Milestone
![Page 176: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/176.jpg)
Recap: Discrete Mathematics
● The past five weeks have focused exclusively on discrete mathematics:
Induction Functions
Graphs The Pigeonhole Principle
Relations Mathematical Logic
Set Theory Cardinality● These are building blocks we will use
throughout the rest of the quarter.● These are building blocks you will use
throughout the rest of your CS career.
![Page 177: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/177.jpg)
Next Up: Computability Theory
● It's time to switch gears and address the limits of what can be computed.
● We'll explore these questions:● How do we model computation itself?● What exactly is a computing device?● What problems can be solved by computers?● What problems can't be solved by computers?
● Get ready to explore the boundaries of what computers could ever be made to do.
![Page 178: web.stanford.eduweb.stanford.edu/class/archive/cs/cs103/cs103.1194/lectures/13... · Theorem: The sum of the first n powers of two is 2n – 1. Proof: Let P(n) be the statement “the](https://reader033.vdocuments.us/reader033/viewer/2022041921/5e6c1107efc44d6d3e21d30e/html5/thumbnails/178.jpg)
Next Time
● Formal Language Theory● How are we going to formally model
computation?● Finite Automata
● A simple but powerful computing device made entirely of math!
● DFAs● A fundamental building block in computing.