Download Counting Elements in a List - Notes | CMSC 250 and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!
Counting Elements in a List
- How many integers in the list from 1 to 10?• How many integers in the list from m to n?
(assuming m <= n)
How many in a list divisible by something:• How many positive three digit integers are there?
- (this means only the ones that require 3 digits)– 999 – 100 + 1 = 900
- How many three digit integers are divisible by 5?
- think about the definition of divisible by
x | y
↔ ∃
k
∈
Z, y = kx
and then count the k’s that work
100, 101, 102, 103, 104, 105, 106,… 994, 995, 996, 997, 998, 99920*
21*
…
199*
- count the integers between 20 and 199– 199 – 20 + 1 = 180
Flipping Two Coins
- Sample Space = {(H,H), (H,T), (T,H), (T,T)}• Probability of no heads• Probability of at least one head• Probability of same sides on the two coins• Note: probability & actual outcomes often differ
Standard Playing Cards
- values: 2,3,4,5,6,7,8,9,10,J,Q,K,A• suits: D(
), H(
), S(
), C(
- probability of drawing the Ace of Spades• probability of drawing a Spade• probability of drawing a face card• probability of drawing a red face card
Multi-level Probability
- If I toss a coin once – the probability of Head = ½• If I toss that coin 5 times
- the probability of all heads– the probability of exactly 4 heads
5 (^12)
1 2
1 2
1 2
1 2
1 2
=
5 (^52)
Multiplication Rule
st
step can be performed n
1
ways
nd
step can be performed n
2
ways
• …• K
th
step can be performed n
k^
ways
- operation can be performed n
*n 1
2
…n
k^
ways
n(A)=3, n(B)=2, n(C)=
- n(AxBxC) = 24– n(AxB) = 6
n((AxB)xC) = 24
What if A wins 2 of every 3 games?•
Each line for A must have a 2/
-^
Each line for B must have a 1/
-^
How likely is A to win the tournament?
-^
How likely is B to win the tournament?
Using the Multiplication Rule for
Selecting a PIN
- Number of 4 digit PINs of (0,1,2,.)
- with repetition allowed = 4444=256– with no repetition allowed = 4321=
- Extra Rules : -. (the period) can’t be first or last– 0 can’t be first - with repetition allowed = 2443• without repetition allowed = 222
Difference Rule Formally
- If A is a finite set and B
A, then
n(A-B) = n(A) – n(B)
- One Application:probability of the complement of an event
P(E’) = P(E
c ) = 1-P(E)
PINs with less specified length
Addition Rule
- Assume it can be a 2,3 or 4 length PINPartition the problem
number of 2 length PINs w/rep allowed: 44 = 16number of 3 length PINs w/rep allowed: 444 = 64number of 4 length PINs w/rep allowed: 4444 = 256 Number PINs if allowing length of 2,3 or 4 = 336
Another example for
Multiplication Rule and Addition Rule• How many 3 digit integers are divisible by 5?
9101 = 90
9101 = 90
- These form a partition with the set of numbers divisible
by 5 so
Where Multiplication Rule Doesn’t Work• People= {Angel, Bob, Carol, Dan}• need to be appointed as
- president, vice-president, and treasurer– nobody can hold more than one office– Angel doesn’t want to be president– Only Bob and Dan want to be vice-president
Permutations
-^
Different ways of arranging objects– in a line or circle– without duplication/ all items distinguishable– note: order is taken into account
-^
Number of linear permutations of N objects = N!N possible for 1
st^
position * (N-1) for 2
nd
-^
Number of circular permutations of N objects = (N-1)!Fix one person,then (N-1) possible for next position * (N-2) for 2
nd
r-Permutations
If there are n things in the set,and you want to line-up only r of them.•^
Example: Class = {Alice, Bob, Carol, Dan}
- select a president and a vice president to represent the class
r
n
n
P
r
n
P
n
r