Will Monroe with materials by Mehran Sahami and Chris...
Transcript of Will Monroe with materials by Mehran Sahami and Chris...
![Page 1: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/1.jpg)
Combinatorics
Will MonroeJune 28, 2017
with materials byMehran Sahamiand Chris Piech
![Page 3: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/3.jpg)
Logistics: Problem Set 1
14 questions (#1: tell me about yourself!)
Due: Wednesday, July 5 (before class)
Handwrite and scan
Word / Google Doc / ...
LaTeX(see website for getting started!)
EmojiOne
![Page 4: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/4.jpg)
Logistics: Office hours
For SCPD: Thursday afternoon also online (Hangouts)!
![Page 5: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/5.jpg)
Logistics: Textbook (or not)
Sheldon RossA First Course in Probability9th (or 8th) Edition
Optional! Has lots of helpful examples.
Suggested readings on website.
Go up two floors for copies on reserve(Terman Engineering Library)
![Page 6: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/6.jpg)
Review: Principle of Inclusion/Exclusion
The total number of elements in two sets is the sum of the number of elements of each set,minus the number of elements in both sets.
|A∪B|=|A|+|B|−|A∩B|
3 4
3+4-1 = 6
![Page 7: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/7.jpg)
Review: General principle of counting
An experiment consisting of two or more separate parts has a number of outcomes equal to the product of the number of outcomes of each part.
|A1×A2×⋯×An|=∏i
|A i|
colors: 3
shapes: 4
total:4 · 3 = 12
![Page 8: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/8.jpg)
Permutations
The number of ways of orderingn distinguishable objects.
n ! =1⋅2⋅3⋅...⋅n=∏i=1
n
i
![Page 9: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/9.jpg)
Example: Servicing computers9 computers to be scheduled for maintenance.
How many possible orders?
![Page 10: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/10.jpg)
Example: Servicing computers
Pick the first: 9 choices
9 computers to be scheduled for maintenance.
How many possible orders?
![Page 11: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/11.jpg)
Example: Servicing computers9 computers to be scheduled for maintenance.
How many possible orders?
Pick the second: 8 choices
9
![Page 12: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/12.jpg)
Example: Servicing computers9 computers to be scheduled for maintenance.
How many possible orders?
Pick the third: 7 choices
9 8
![Page 13: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/13.jpg)
Example: Servicing computers9 computers to be scheduled for maintenance.
How many possible orders?
9 8 7 6 5 4 3 2 1
![Page 14: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/14.jpg)
Example: Servicing computers9 computers to be scheduled for maintenance.
How many possible orders?
9 8 7 6 5 4 3 2 1
9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 362,880
9!
![Page 15: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/15.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
![Page 16: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/16.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
![Page 17: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/17.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
4!
![Page 18: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/18.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
4! 3!
![Page 19: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/19.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
4! 3! 2!
![Page 20: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/20.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
4! × 3! × 2! = 288
4! 3! 2!
![Page 21: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/21.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.
Same type have to be serviced together.
How many possible orders?
4! × 3! × 2! × 3! = 1,728
4! 3! 2!
3!
![Page 22: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/22.jpg)
Review: Binary search trees
binary: Every node has at most two children.
2
1 4
3 5
![Page 23: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/23.jpg)
Review: Binary search trees
binary: Every node has at most two children.
search: Root value is - greater than values in the left subtree - less than values in the right subtree
2
1 4
3 5
![Page 24: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/24.jpg)
Degenerate binary search trees
6
degenerate: Every node has at most one child.
5
1
4
2
3
![Page 25: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/25.jpg)
Degenerate binary search trees
3
degenerate: Every node has at most one child.
2
1 How many different BSTs containing the
values 1, 2, and 3 are degenerate?
![Page 26: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/26.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
![Page 27: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/27.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
3! = 6
![Page 28: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/28.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
3! = 6
![Page 29: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/29.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
2
3! = 6
![Page 30: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/30.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
2
3
3! = 6
![Page 31: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/31.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
2
3
1
3! = 6
![Page 32: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/32.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
2
3
1
3
3! = 6
![Page 33: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/33.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
1
2
3
1
3
2
3! = 6
![Page 34: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/34.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
3
2
1
1
2
3
1
3
2
2
31
2
31
3
1
2
3! = 6
![Page 35: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/35.jpg)
Degenerate binary search treesBSTs can be listed by order of insertion.
How many possible orders for inserting 1, 2, and 3?
1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1
3
2
1
1
2
3
1
3
2
2
31
2
31
3
1
2
3! = 6
4 degenerate BSTs
![Page 36: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/36.jpg)
Permutations
The number of ways of orderingn distinguishable objects.
n ! =1⋅2⋅3⋅...⋅n=∏i=1
n
i
![Page 37: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/37.jpg)
Permutations withindistinct elements
( nk1 , k2 ,…, km
) =n !
k1!k2 !…km!
k2 identical
n
The number of ways of ordering n. objects, where some groups are indistinguishable.
k1 identical
![Page 38: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/38.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
![Page 39: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/39.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
5! = 120 ?
![Page 40: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/40.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
5! = 120
![Page 41: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/41.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
5!
![Page 42: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/42.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 005!
![Page 43: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/43.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 005!
![Page 44: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/44.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 005!
![Page 45: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/45.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 005!
2!
![Page 46: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/46.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 00
·
5!
2!
3!
![Page 47: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/47.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 00
·
·
5!
2!
3!
x
![Page 48: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/48.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 00
·
·
5!
2!
3!
x
5!=2!⋅3!⋅x
![Page 49: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/49.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 00
·
·
5!
2!
3!
x
x=5 !
2!⋅3!
![Page 50: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/50.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
![Page 51: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/51.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
9!
![Page 52: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/52.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
4!
9!
![Page 53: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/53.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
4! 3!
9!
![Page 54: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/54.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
4! 3! 2!
9!
![Page 55: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/55.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
4! 3! 2!
9!
( 94,3,2)=
9!4 !⋅3!⋅2!
=1,260
![Page 56: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/56.jpg)
Example: Servicing computers4 laptops, 3 tablets, 2 desktops.Same type are indistinguishable.
How many possible orders?
4! 3! 2!
9!
( 94,3,2)=
9 !4 !⋅3 !⋅2!
=1,260
![Page 57: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/57.jpg)
Example: Passcode guessing4-digit passcode on a phone.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
![Page 58: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/58.jpg)
Example: Passcode guessing4-digit passcode on a phone.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
104=10,000
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
![Page 59: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/59.jpg)
Example: Passcode guessing4 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
![Page 60: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/60.jpg)
Example: Passcode guessing4 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
4 !=24
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
![Page 61: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/61.jpg)
Example: Passcode guessing3 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
![Page 62: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/62.jpg)
Example: Passcode guessing3 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
3 smudges =(less, same, more)possibilities vs.4 smudges?
A) lessB) sameC) more
![Page 63: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/63.jpg)
Example: Passcode guessing3 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
3⋅4 !
2!1!1!=12
![Page 64: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/64.jpg)
Example: Passcode guessing3 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
3⋅4 !
2!1!1!=36
![Page 65: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/65.jpg)
Example: Passcode guessing2 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
![Page 66: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/66.jpg)
Example: Passcode guessing2 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
Two and two
Three and one
![Page 67: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/67.jpg)
Example: Passcode guessing2 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
Two and two
Three and one
4 !2!2!
=6
![Page 68: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/68.jpg)
Example: Passcode guessing2 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
Two and two
Three and one
4 !2!2!
=6
2⋅4 !3!1!
=8
![Page 69: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/69.jpg)
Example: Passcode guessing2 smudges on phone for a 4-digit passcode.
How many possible codes?
1 2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ
0
Two and two
+
Three and one
4 !2!2!
=6
2⋅4 !3!1!
=8
=14
![Page 70: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/70.jpg)
Permutations withindistinct elements
( nk1 , k2 ,…, km
) =n !
k1!k2 !…km!
k2 identical
n
The number of ways of ordering n. objects, where some groups are indistinguishable.
k1 identical
![Page 71: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/71.jpg)
Break time!
![Page 72: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/72.jpg)
Combinations
(nk ) =n !
k !(n−k)!
choose k
n
The number of unique subsets of size k from a larger set of size n. (objects are distinguishable, unordered)
![Page 73: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/73.jpg)
Picking drink flavors5 drink flavors.
How many ways to pick 3?
![Page 74: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/74.jpg)
Picking drink flavors5 drink flavors.
How many ways to pick 3?
(52)=5!
2!3!=10
5!
![Page 75: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/75.jpg)
Picking drink flavors5 drink flavors.
How many ways to pick 3?
5!
2!3!
5!3!⋅2!
=( 53,2)
![Page 76: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/76.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00 =
1 0 1 00
·
·
5!
2!
3!
x
x=5 !
2!⋅3!=( 5
2,3)
![Page 77: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/77.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
=
How many subsets of positions in a five-bit stringare possible for placing two 1's?
x=5 !
2!⋅3!=( 5
2,3)
![Page 78: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/78.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
=
How many subsets of positions in a five-bit stringare possible for placing two 1's?
x=5 !
2!⋅3!=( 5
2,3)=(52)
![Page 79: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/79.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
=
How many subsets of positions in a five-bit stringare possible for placing three 0's?
x=5 !
3!⋅2!=( 5
3,2)=(53)
![Page 80: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/80.jpg)
Return of the binary stringsHow many distinct bit strings are there
consisting of three 0's and two 1's?
1 0 1 00
=
How many subsets of positions in a five-bit stringare possible for placing three 0's?
x=5 !
3!⋅2!=( 5
3,2)=(53)=(52)
![Page 81: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/81.jpg)
Binomial coefficient
(nk ) =n !
k !(n−k)!
choose k
n
![Page 82: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/82.jpg)
Combinations
(nk ) =n !
k !(n−k)!
choose k
n
The number of unique subsets of size k from a larger set of size n. (objects are distinguishable, unordered)
![Page 83: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/83.jpg)
Bucketing
The number of ways of assigning n distinguishable objects to a fixedset of k buckets or labels.
kn
k buckets
n objects
![Page 84: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/84.jpg)
String hashing
n = 3 buckets
m = 5 strings
“wild cherry”“mountain cooler”
“sugar”
“not sugar”
“pacific cooler”
![Page 85: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/85.jpg)
String hashing
n = 3 buckets
m = 5 strings
“wild cherry”“mountain cooler”
“sugar”
“not sugar”
“pacific cooler” 3
33
33
= 35
![Page 86: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/86.jpg)
Divider method
The number of ways of assigning n indistinguishable objects to a fixedset of k buckets or labels.
(n+(k−1)
n )
k buckets
n objects
(k - 1 dividers)
![Page 87: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/87.jpg)
Indistinguishable drinks?
![Page 88: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/88.jpg)
Indistinguishable drinks?
![Page 89: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/89.jpg)
Indistinguishable drinks?
![Page 90: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/90.jpg)
Indistinguishable drinks?
![Page 91: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/91.jpg)
Indistinguishable drinks?
![Page 92: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/92.jpg)
Indistinguishable drinks?
3 students → 3 – 1 = 2 dividers
5 drinks
![Page 93: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/93.jpg)
Indistinguishable drinks?
7 objects
![Page 94: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/94.jpg)
Indistinguishable drinks?
7 objects
5 drinks
![Page 95: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/95.jpg)
Indistinguishable drinks?
7 objects
5 drinks
![Page 96: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/96.jpg)
Indistinguishable drinks?
7 objects
5 drinks
![Page 97: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/97.jpg)
Indistinguishable drinks?
7 objects
5 drinks (75)=(5+(3−1)
5 )=21
![Page 98: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/98.jpg)
Investing in startups
million dollar bill image: Simon Davison
![Page 99: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/99.jpg)
Investing in startups
million dollar bill image: Simon Davison
![Page 100: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/100.jpg)
Investing in startups
million dollar bill image: Simon Davison
![Page 101: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/101.jpg)
Investing in startups
million dollar bill image: Simon Davison
![Page 102: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/102.jpg)
Investing in startups
million dollar bill image: Simon Davison
![Page 103: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/103.jpg)
Investing in startups
million dollar bill image: Simon Davison
(10+310 )=286
![Page 104: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/104.jpg)
Permutations
The number of ways of orderingn distinguishable objects.
n ! =1⋅2⋅3⋅...⋅n=∏i=1
n
i
![Page 105: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/105.jpg)
Permutations withindistinct elements
( nk1 , k2 ,…, km
) =n !
k1!k2 !…km!
k2 identical
n
The number of ways of ordering n. objects, where some groups are indistinguishable.
k1 identical
![Page 106: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/106.jpg)
Combinations
(nk ) =n !
k !(n−k)!
choose k
n
The number of unique subsets of size k from a larger set of size n. (objects are distinguishable, unordered)
![Page 107: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/107.jpg)
Bucketing
The number of ways of assigning n distinguishable objects to a fixedset of k buckets or labels.
kn
k buckets
n objects
![Page 108: Will Monroe with materials by Mehran Sahami and Chris Piechweb.stanford.edu/class/archive/cs/cs109/cs109.1178/lectures/02... · Combinatorics Will Monroe June 28, 2017 with materials](https://reader033.fdocuments.us/reader033/viewer/2022041505/5e247755b63ebc78555b30b6/html5/thumbnails/108.jpg)
Divider method
The number of ways of assigning n indistinguishable objects to a fixedset of k buckets or labels.
(n+(k−1)
n )
k buckets
n objects
(k - 1 dividers)