Counting / Combinatorics
8-8 •• 8-8 •• •• §go 6You a 6%Ho
•• 8-6 8-8 66 66
μ68 68 •8 66
Copyright By PowCoder代写 加微信 powcoder
••I• • . •too
•• 68 6• 6-8 6•
68÷ ¥¥••tt•
•☒•6•• • •••
#** 88••••
Lecture Notes
Northeastern
University
1Intro There
& Counting /Combinatorics a re lots in as w e
to count is o n e
steps in algorithm
motivating
example : How many
How many pins ?
are their have 4- digits .
– digits :
264 = 524 =
lowercase : upper / lower
More passwords ⇒
There is a havea2
” Brute force ” possibilities)
. can’t (attempting all
of things E.an-
better then The security of
7- 10 characters d.
uppercase , lowercase . jets 12 letters
} less obvious
how to count the
I 2 digits
size of this search space
restrictions
10,000 = 104 to possibilities
why you digit pin !!
size the .
why? To combat human nature : short passwords.
are easy to remember
in data breaches
patterns o n keyboard .
Is the shrinkage of
the PW space substantial?
Binary # s ( n bits ⇒ 2″
I 1 1 1 15 = 8+4+2+1
%% 2×2×2=24
possibilities
How many graphs are there on vertices ✓ = {A.B.C, D, E }
1=4 =14(L = to
:☒¥: B•!•D
AB AC AD AE BC BD BE CD CE DE
:I1I1I11I1I
I°I°I0I0I0
each pair (u,v)
w e decide whether
Include an edge , so we have
Sum and Product
pants-r-h-spatspa.rs
c a n w e a r o n e o r another . S o
h a v . 8 -16 = 14 options
Pantandkirts
Product Rule IB are
topickam aEA and ÷ .ie?I.::E ! ”
IA✗BI=/A/× /B/
m ore generally, A , , Az ,
/A.✗Azx. . -An/=/A, /✗ /Az/x – – – × /An/
char passwords : upper / lower /digit .
How many Pws do you have ?
A = { a ,b,c
1A 1 = 6 2
62✗62✗62✗62=62″=
14,776,336
” for each position I have 62
62 choices for position 1 AIN
Pick Representative from each d three
possibilities
Think about the problem in
English : multiplication /product
” OR” ⇒ addition /sum
this That ” Pick or
If A g B are disjoint finite then the # ways of picking a n
object from A of B is /At/B/
A n a l l mutually -.. then
1A, u Azu- . .UA,/=/A/+/Az/+. . ,
F-xamplei.RU/eTe-
5- spin sequences
✗ 38 × 38 × 38 × 38 = 385
( Product Rule )
5.es#is?efuencesal-fsame
#allsame color=/G/+/Ri/B/
( sum Rule
14=14–15×5I. Is Is
Y¥iÉ!ÉÉirs
18 /- IG/ – /RI-
385-2.185-32
e.g2,5,32,7,25
38 ✗ 37 ✗ 36
This is a 5- Permutation
this soon . ) [T
Permutations
A mix of Red
g r e e n)
We know that there are
( n o g re e n
365 – 2.185
some Red Isomeblack
Example-n.songplayl.is/-s-
a) # 7- song playlists
11 ✗ 10 ✗ 9 ✗ 8 × -7 ✗6×5
OnlyIM or onlyRs?
IP/ =/Rsl + Hml
IP/ =/Pa/ + (Ps/+1Pa/+ |P,o|
songs but Atleast
each artist ?
Mix/ =p, /-1¥/-1¥!
a 7 – song Playlist?
Must Alternate
R – I- R – E .E E
2 1 ,6 0 0
I_ _ R _ I_ R
21,600+14,400=36000
•j÷iÉ÷i÷÷÷
deck of S2 c a rd s
set of red cards = 2.6 set of face c a rd s = 1 2
How many ways can card that is red
I pick of a
NII 26+12=38 ✗(In double
face card? counting)
because Then
26+12-6=320
red face cards
of Inclusion /Exclusion says
LAUB/ =/A/ + /B)- /AnB/
T . h 4r e e . s e / – s –
elementfromAorB
Itstillworks whenthesetsare
“Pick an BorC
For larger sets , its a continuing series of inclusions É exclusions
/ =/ /AnBl- /An
4 Exampk-s-continue.ca chars ) Pws between 6 &to
w/ at least one letter
lower> digits.
we have to break up into pieces
Stef Pick length:
6 01 7 I 8
⇒ sum rule .
Step2_ Focus o n length
Pick 1st char ante ?nor a re
– . . – and 6th
P.ge/ength#lPo/–
rule to account for
By sum /PI =
rule : É¢2″ 10
szi ) 27×1017 yuzoo million
Permutations
traeigaeman
A salesman has to visit
visit the cities This !
cities . you
cost , gas , # of left turns , etc
We could try all possibilities to find The
best solution How many ways a re there ? .
We might be trying to minimize time,
10 options fo r first 10 ✗
ANI 9 options for
8 options fo r third
” to factorial
25! I 1.55 ✗ 10″ (4.12 ✗1017 seconds)
so ⇒ 37 million choices
per second since
the beginning oftime
will find us our optimal
For many problems , best solutions require w e consider a ll possibilities
guaranteed
best . close
(so we findsomething
instead . )
toordern objects= n!
Each ordering is a ” permutation ”
How many ways can you visit 3 out
10•9•8 = 10!=
T T P ⇒ (10-3) !
Permutation : –
Permutations .: # permutations = n ! n!=n(n-1).cn-2). … 3.2.1
-..- G.rh)= n.cn 1) In-
Examples : a) to packages ⇒ 10 !
K terms I 3.6 million
b) 61,0 packages
• 4!• 6!=34,560
Permutations with identical objects
many permutations of the letters banana”
n=6 , but many of the n ! = 720 arrangements are the same .
45-4.3-21.1-1
3!2! asT Tns
31.12.11 ✗ X = 60 arrangements .
n objects , k
ma = # of occurrences of the
Kth of type
,nen,#pemuμ,m=mn÷ym
Combinations
An unordered subset of K out of n
o b je c ts
e.g. we hate to pick 3
truck , but what order
deliver pick } of co the 3
↳ efine the
delivery sequence
3 packages.
combinations
=C(n,k)=(I)=f¥
Calculating
Combinations
sn.H.tn:-) ÷÷÷:*
rest cancel ) ;¥ / The –
I Dont Cancel
“” ” Ir “‘ ” cc
. 11=acatb)b
%??sbt ecg”01 1 strings of lengths .
How many ?
How many h a v e exactly 3 Is ?
into the formula :
= E.IE#-I– 10
Reason i t 5- length
5 I 0000,01000 – – –
#of1s_gHoqstnnjs_
01100 → 10011
-5 I1110,11101,- – -. • 11111
Recursively
HEY:) * ETH:)
1:14: -14¥ )
I 🙂 -11,4+14+1:) -1
={a.b,c d,e}
How many elements of PLA ) are sizes ?
O l l 0 I = {b.c.e}
Iooll={a)de}
= # of 5- length bit
= (3)= to ;
(shortest paths ) from
All lattice paths are length 5, move up 2times andright3times.
We encode up= 0 , right= 1
the bright green path is 01011
S o again this
equivalent to finding 5- bit strings with 3 ones .
H o w m a n y p e r mu t a t i o n s o f t h e l e t t e r s A.B, C , D, E, F which do not contain
the substring BAD
for example FB-AD.GE , FCE BAD , etc .
Permutations
= # Total Permutations – # Illegal
permutations
t h e 4 elements
c)E,F, BAD
a permutation
rotational
☐6 1 = 4 6 4← ← to
# Permutations = n÷ = (n !
5 beads chosen fro m 9dÉads for
The necklace can
necklaces ? permuted
How many t o ± P l n K ← k beads
be flipped over
‘ -2k from
0–0 flip I t rotational =151
symmetry symmetry
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com