Transcript CS121

Week 9 - Friday




What did we talk about last time?
Partial orders
Total orders
Basic probability
 Event
 Sample space


Monty Hall
Multiplication rule
There are 10 thieves who have just stolen an
enormous pile of loot: gold, jewels, solid state
drives, and so on
 The thieves need to find a way to divide it all
equally
 Give an algorithm such that each of the 10
thieves believe that he is getting at least 1/10 of
the loot
 Hint: When you were a kid, how did your
mother have you and your brother or sister
divide the last piece of cake?

How many different ways can the letters in the
word "WOMBAT" be permuted?
 How many different ways can "WOMBAT" be
permuted such that "BA" remains together?
 What is the probability that, given a random
permutation of "WOMBAT", the "BA" is
together?
 How many different ways can the letters in
"MISSISSIPPI" be permuted?
 How many would it be if we don't distinguish
between copies of letters?




What if you want to seat 6 people around a
circular table?
If you only care about who sits next to whom
(rather than who is actually in Seat 1, Seat 2,
etc.) how many circular permutations are
there?
What about for n people?


An r-permutation of a set of n element is an
ordered selection of r elements from the set
Example: A 2-permutation of {a, b, c} includes:







ab
ac
ba
bc
ca
cb
The number of r-permutations of a set of n
elements is P(n,r) = n!/(n – r)!



What is P(5,2)?
How many 4-permutations are there in a set
of 7 objects?
How many different ways can three of the
letters in "BYTES" be written in a row?

If a finite set A equals the union of k distinct
mutually disjoint subsets A1, A2, … Ak, then:
N(A) = N(A1) + N(A2) + … + N(Ak)



How many passwords are there with length 3
or smaller?
Assume that a password is only made up of
lower case letters
Passwords with length 3 or smaller fall into 3
disjoint sets
 Number of passwords with length 1
 Number of passwords with length 2
 Number of passwords with length 3

Total passwords = 26 + 262 + 263 = 18278

If A is a finite set and B is a subset of A, then
N(A – B) = N(A) – N(B)

Example:
 Recall that a PIN has 4 digits, each of which is one
of the 26 letters or one of the 10 digits
 How many PINs contain repeated symbols?
 What is the probability that a PIN contains a
repeated symbol?

If A, B, C are any finite sets, then
N(A  B) = N(A) + N(B) – N(A  B)

And,
N(A  B  C) = N(A) + N(B) + N(C) – N(A  B)
– N(A  C) – N(B  C) + N(A  B  C)


How many integers from 1 through 1,000 are
multiples of 3 or multiples of 5?
How many integers from 1 through 1,000 are
neither multiples of 3 nor multiples of 5?
Consider a survey of 50 students about the programming
languages they know
 The results are:












30 know Java
18 know C++
26 know ML
9 known both Java and C++
16 know both Java and ML
8 know both C++ and ML
47 know at least one of the three
How many students know none of the three?
How many students know all three?
How many students know Java and C++ but not ML?
How many students know Java but neither C++ nor ML?
Student Lecture

How many different subsets of size r can you
take out of a set of n items?
 Subset of size 3 out of a set of size 5?
 Subset of size 4 out of a set of size 5?
 Subset of size 5 out of a set of size 5?
 Subset of size 1 out of a set of size 5?
n
 This is called an r-combination, written  
r 



In r-permutations, the order matters
In r-combinations, the order doesn't
Thus, the number of r-combinations is just
the number of r-permutations divided by the
possible orderings
 n  P(n, r )
n!
  

r!
r !(n  r )!
r 

How many ways are there to choose 5 people
out of a group of 12?

What if two people don't get along? How
many 5 person teams can you make from a
group of 12 if those two people cannot both
be on the team?

How many five-card poker hands contain two
pairs?

If a five-card hand is dealt at random from an
ordinary deck of cards, what is the probability
that the hand contains two pairs?



What if you want to take r things out of a set
of n things, but you are allowed to have
repetitions?
Think of it as putting r things in n categories
Example: n = 5, r = 4
1
x


2
3
4
xx
x
We could represent this as x||xx|x|
That's an r x's and n – 1 |'s
5


So, we can think of taking an r-combination
with repetitions as choosing r items in a
string that is r + n – 1 long and marking those
as x's
Consequently, the number of r-combinations
with repetitions is
r  n 1


 r 


Let's say you grab a handful of 10 Starbursts
Original Starbursts come in
 Cherry
 Lemon
 Strawberry
 Orange


How many different handfuls are possible?
How many possible handfuls will contain at
least 3 cherry?

This is a quick reminder of all the different
ways you can count things:
Repetition Allowed
Repetition Not Allowed
Order Matters
Order Doesn't Matter
nk
k  n 1


 k 
P(n,k)
n
 
k 



Binomial theorem
Probability axioms
Expected values

Work on Homework 7
 Due tonight before midnight

Keep reading Chapter 9