Anda di halaman 1dari 9

How​ ​to​ ​Count:​ ​The​ ​Basics

By​ ​Raymond​ ​Chou;​ ​October​ ​11,​ ​2017

Introduction

I​ ​know​ ​it​ ​kind​ ​of​ ​seems​ ​ridiculous,​ ​having​ ​to​ ​read​ ​a​ ​paper​ ​on​ ​how​ ​to​ ​count​ ​-​ ​after​ ​all,​ ​have​ ​we
not​ ​been​ ​taught​ ​how​ ​to​ ​do​ ​that​ ​since​ ​childhood?​ ​Well...here’s​ ​a​ ​question.

Example​ ​1.​ ​Albert,​ ​Bernard,​ ​and​ ​Chelsea​ ​go​ ​to​ ​the​ ​movies​ ​with​ ​their​ ​“friend​ ​group,”​ ​which
consists​ ​of​ ​10​ ​people.​ ​The​ ​trouble​ ​is,​ ​Albert,​ ​Bernard,​ ​and​ ​Chelsea​ ​all​ ​mutually​ ​hate​ ​each​ ​other,
and​ ​no​ ​2​ ​of​ ​the​ ​3​ ​may​ ​sit​ ​next​ ​to​ ​each​ ​other.​ ​All​ ​of​ ​the​ ​“friends”​ ​are​ ​to​ ​sit​ ​in​ ​the​ ​same​ ​row.​ ​If
there​ ​are​ ​12​ ​seats​ ​in​ ​a​ ​row,​ ​how​ ​many​ ​possible​ ​seating​ ​arrangements​ ​are​ ​there?

My,​ ​my,​ ​my,​ ​what​ ​a​ ​problem.​ ​We’ll​ ​get​ ​back​ ​to​ ​this​ ​problem​ ​later,​ ​after​ ​we​ ​introduce​ ​a​ ​few
tools​ ​that​ ​may​ ​or​ ​may​ ​not​ ​be​ ​useful.

The​ ​Multiplication​ ​Principle

If​ ​events​ ​A​ ​and​ ​B​ ​are​ ​independent,​ ​and​ ​there​ ​are​ ​m​ ​outcomes​ ​for​ ​event​ ​A,​ ​and​ ​n​ ​outcomes​ ​for
event​ ​B,​ ​then​ ​there​ ​are​ ​m*n​ ​outcomes​ ​for​ ​the​ ​two​ ​events​ ​together.

If​ ​you​ ​have​ ​5​ ​pairs​ ​of​ ​shoes,​ ​and​ ​7​ ​pairs​ ​of​ ​socks,​ ​you​ ​not​ ​only​ ​need​ ​to​ ​buy​ ​more​ ​socks​ ​(why​ ​do
you​ ​have​ ​so​ ​many​ ​shoes?),​ ​but​ ​you​ ​will​ ​have​ ​5*7​ ​=​ ​35​ ​different​ ​possible​ ​combinations​ ​of​ ​shoes
and​ ​socks.​ ​To​ ​see​ ​why​ ​this​ ​is,​ ​let​ ​us​ ​consider​ ​the​ ​ordered​ ​pairs​ ​of​ ​the​ ​form​ ​(socks,​ ​shoes).

Exercise:​ ​Imagine​ ​you​ ​only​ ​have​ ​2​ ​pairs​ ​of​ ​shoes,​ ​and​ ​4​ ​pairs​ ​of​ ​socks.​ ​Make​ ​a​ ​list​ ​of​ ​ordered
pairs​ ​of​ ​the​ ​shoes​ ​and​ ​socks,​ ​and​ ​verify​ ​that​ ​you​ ​do​ ​indeed​ ​have​ ​8​ ​possible​ ​combinations.

You​ ​may​ ​draw​ ​a​ ​tree​ ​diagram​ ​(I’m​ ​too​ ​lazy​ ​to​ ​do​ ​it​ ​here)​ ​to​ ​see​ ​why​ ​this​ ​works.

In​ ​mathematics,​ ​many​ ​properties/theorems/principles​ ​are​ ​typically​ ​stated​ ​for​ ​only​ ​two​ ​objects
(since​ ​that​ ​is​ ​all​ ​you​ ​really​ ​need),​ ​but​ ​they​ ​actually​ ​can​ ​apply​ ​to​ ​any​ ​finite​ ​amount​ ​of​ ​objects.
The​ ​multiplication​ ​principle​ ​is​ ​stated​ ​for​ ​strictly​ ​two​ ​events​ ​-​ ​but​ ​it​ ​turns​ ​out​ ​a​ ​more​ ​general
version​ ​of​ ​this​ ​is​ ​true​ ​as​ ​well.

If​ ​events​ ​A​1​ ,​ ​ ​A​2​ ,​ ​ ​…,​ ​A​n​​ ​are​ ​independent,​ ​and​ ​there​ ​are​ ​m​1​​ ​outcomes​ ​for​ ​A​1​ ,​ ​ ​m​2​​ ​outcomes​ ​for​ ​A​2​ ,​
…,​ ​and​ ​mn​ ​outcomes​ ​for​ ​A​n​ ,​ ​ ​then​ ​there​ ​are​ ​m​1*m ​ ​2*...*m
​ ​n​​ ​outcomes​ ​for​ ​the​ ​n​ ​events​ ​together.
Exercise:​ ​Prove​ ​this​ ​by​ ​induction.

Factorials​ ​and​ ​Permutations

We​ ​are​ ​now​ ​ready​ ​for​ ​our​ ​first​ ​tool:​ ​the​ ​factorial!​ ​Suppose​ ​there​ ​are​ ​n​ ​people​ ​standing​ ​in​ ​a​ ​line.
(And​ ​also,​ ​assume​ ​that​ ​all​ ​of​ ​these​ ​people​ ​are​ ​different)​ ​How​ ​many​ ​ways​ ​can​ ​you​ ​order​ ​the​ ​n
people​ ​in​ ​line?

Well,​ ​the​ ​first​ ​thing​ ​we​ ​must​ ​do​ ​is​ ​to​ ​create​ ​a​ ​process​ ​for​ ​counting​ ​the​ ​different​ ​ways.​ ​Of
course,​ ​we​ ​could​ ​always​ ​end​ ​up​ ​just​ ​listing​ ​literally​ ​every​ ​single​ ​possible​ ​variation​ ​(in​ ​fact,​ ​in​ ​we
are​ ​desperate​ ​enough,​ ​we​ ​may​ ​resort​ ​to​ ​this​ ​-​ ​sometimes​ ​computers​ ​do​ ​just​ ​that),​ ​but​ ​as
human​ ​beings,​ ​perhaps​ ​we​ ​can​ ​find​ ​some​ ​faster​ ​way.​ ​And​ ​indeed,​ ​there​ ​is.

One​ ​thing​ ​we​ ​can​ ​do​ ​is​ ​to​ ​begin​ ​manually​ ​counting,​ ​observe​ ​a​ ​pattern,​ ​and​ ​quickly​ ​realize​ ​that
we​ ​can​ ​“skip​ ​a​ ​few​ ​steps.”​ ​We​ ​see​ ​that,​ ​if​ ​we​ ​draw​ ​a​ ​tree,​ ​we​ ​have​ ​n​ ​possibilities​ ​for​ ​who​ ​is​ ​to
be​ ​first​ ​in​ ​line.​ ​For​ ​each​ ​of​ ​the​ ​people​ ​that​ ​are​ ​first​ ​in​ ​line,​ ​we​ ​have​ ​n-1​ ​choices​ ​for​ ​who​ ​is​ ​to​ ​be
second.​ ​After​ ​choosing​ ​the​ ​first​ ​two​ ​people,​ ​we​ ​see​ ​that​ ​there​ ​are​ ​n-2​ ​choices​ ​for​ ​who​ ​is​ ​to​ ​be
third,​ ​n-3​ ​choices​ ​for​ ​who​ ​is​ ​fourth,​ ​and​ ​so​ ​on.​ ​In​ ​general,​ ​for​ ​any​ ​1​ ​=<​ ​k​ ​<=​ ​n,​ ​there​ ​are​ ​n-k+1
choices​ ​for​ ​who​ ​is​ ​to​ ​be​ ​the​ ​k​th​ ​person​ ​in​ ​line.

Multiplying​ ​these​ ​together,​ ​we​ ​obtain:

n*(n-1)*(n-2)*...*3*2*1​ ​different​ ​ways.​ ​We​ ​call​ ​this​ ​number​ ​n​ ​factorial​,​ ​or​ ​n!.

If​ ​we​ ​interpret​ ​n!​ ​as​ ​the​ ​number​ ​of​ ​ways​ ​to​ ​arrange​ ​n​ ​people​ ​in​ ​a​ ​line,​ ​then​ ​notice​ ​that​ ​this
means​ ​that​ ​0!​ ​=​ ​1.​ ​How​ ​many​ ​ways​ ​are​ ​there​ ​to​ ​order​ ​0​ ​people​ ​in​ ​a​ ​line?​ ​There’s​ ​exactly​ ​1​ ​way
for​ ​this​ ​to​ ​happen​ ​-​ ​nothing​ ​happens!

Let’s​ ​try​ ​a​ ​more​ ​difficult​ ​problem.

Example​ ​2.​ ​There​ ​are​ ​20​ ​seats​ ​in​ ​a​ ​row​ ​in​ ​a​ ​movie​ ​theatre,​ ​and​ ​a​ ​group​ ​of​ ​8​ ​friends​ ​go​ ​to​ ​watch
a​ ​movie.​ ​How​ ​many​ ​ways​ ​are​ ​there​ ​to​ ​arrange​ ​these​ ​8​ ​children​ ​if​ ​the​ ​only​ ​restriction​ ​is​ ​that​ ​they
all​ ​must​ ​sit​ ​in​ ​the​ ​same​ ​row?

Just​ ​to​ ​clarify,​ ​any​ ​one​ ​of​ ​them​ ​can​ ​sit​ ​in​ ​any​ ​one​ ​of​ ​the​ ​20​ ​chairs​ ​-​ ​as​ ​long​ ​as​ ​no​ ​two​ ​of​ ​them​ ​sit
in​ ​the​ ​same​ ​chair.
An​ ​easy​ ​way​ ​to​ ​count​ ​this​ ​is​ ​to​ ​arrange​ ​them​ ​in​ ​order,​ ​and​ ​have​ ​them​ ​pick​ ​seats.​ ​The​ ​first​ ​friend
has​ ​20​ ​seats​ ​to​ ​pick​ ​from,​ ​the​ ​second​ ​friend​ ​has​ ​19​ ​seats​ ​to​ ​pick​ ​from,​ ​and​ ​so​ ​on,​ ​noting​ ​that
the​ ​8th​ ​friend​ ​has​ ​13​ ​seats​ ​to​ ​pick​ ​from.​ ​So​ ​the​ ​solution​ ​to​ ​our​ ​problem​ ​is:

20*19*18*17*16*15*14*13​ ​=​ ​5,079,110,400.

There​ ​are​ ​over​ ​5​ ​billion​ ​ways​ ​to​ ​organize​ ​just​ ​these​ ​8​ ​friends!​ ​In​ ​general,​ ​when​ ​distributing​ ​k
distinguishable​​ ​(you​ ​can​ ​tell​ ​them​ ​apart,​ ​like​ ​the​ ​friends​ ​in​ ​this​ ​case)​ ​objects​ ​into​ ​n
distinguishable​​ ​boxes​ ​(you​ ​can​ ​tell​ ​them​ ​apart​ ​-​ ​for​ ​example,​ ​each​ ​chair​ ​is​ ​labeled​ ​something
else),​ ​where​ ​only​ ​one​ ​thing​ ​can​ ​go​ ​in​ ​each​ ​box,​ ​there​ ​are:

P(n,k)​ ​=​ ​n*(n-1)*...*(n-k+1)​ ​ways​ ​to​ ​do​ ​this.

It​ ​might​ ​look​ ​like​ ​we​ ​can​ ​make​ ​this​ ​expression​ ​a​ ​little​ ​nicer,​ ​and​ ​in​ ​fact​ ​we​ ​can!

P(n,k)​ ​=​ ​n*(n-1)*...*(n-k+1)​ ​=​ ​[​ ​n*(n-1)*...*(n-k+1)​ ​]​ ​*​ ​(n-k)!​ ​/​ ​(n-k)!​ ​=​ ​n!​ ​/​ ​(n-k)!

This​ ​little​ ​trick​ ​is​ ​called​ ​completing​ ​the​ ​factorial.​ ​We​ ​noticed​ ​that​ ​P(n-k)​ ​looks​ ​like​ ​a​ ​factorial
with​ ​the​ ​end​ ​bit​ ​missing,​ ​so​ ​we​ ​multiplied​ ​and​ ​divided​ ​by​ ​the​ ​rest!

Perhaps​ ​this​ ​formula​ ​tells​ ​us​ ​something​ ​about​ ​P(n,k)​ ​philosophically​ ​as​ ​well​ ​-​ ​which​ ​brings​ ​us​ ​to
our​ ​next​ ​technique:​ ​overcounting​ ​and​ ​dividing/subtracting​ ​away.

A​ ​common​ ​technique​ ​is​ ​to​ ​overcount​ ​the​ ​number​ ​of​ ​things​ ​we​ ​need​ ​(usually​ ​because​ ​it​ ​is​ ​much
easier​ ​to​ ​do​ ​so),​ ​and​ ​then​ ​subtract​ ​away​ ​all​ ​of​ ​the​ ​ones​ ​that​ ​we​ ​don’t​ ​need.​ ​In​ ​this​ ​case,​ ​if​ ​there
are​ ​k​ ​children​ ​that​ ​are​ ​to​ ​go​ ​into​ ​n​ ​seats,​ ​then​ ​we​ ​can​ ​pretend​ ​that​ ​there​ ​are​ ​n-k​ ​“ghost
children.”​ ​Notice​ ​that​ ​there​ ​are​ ​indeed​ ​n​ ​ways​ ​to​ ​order​ ​the​ ​children​ ​AND​ ​the​ ​ghost​ ​children
together!​ ​But​ ​we​ ​overcounted​ ​-​ ​how​ ​many​ ​times​ ​did​ ​we​ ​overcount?​ ​Well,​ ​we​ ​can’t​ ​actually​ ​see
the​ ​ghost​ ​children,​ ​so​ ​we​ ​need​ ​to​ ​divide​ ​away​ ​all​ ​of​ ​the​ ​different​ ​ways​ ​we​ ​can​ ​arrange​ ​them.
Why?​ ​Because​ ​for​ ​each​ ​one​ ​of​ ​our​ ​desired​ ​permutations​ ​(ways​ ​to​ ​arrange​ ​the​ ​real​ ​children),​ ​we
can​ ​keep​ ​those​ ​children​ ​fixed,​ ​and​ ​we​ ​can​ ​arrange​ ​the​ ​n-k​ ​ghost​ ​children​ ​however​ ​we​ ​like!​ ​So
we​ ​overcounted​ ​each​ ​one​ ​of​ ​our​ ​desired​ ​permutations​ ​by​ ​the​ ​number​ ​of​ ​ways​ ​to​ ​arrange​ ​the
ghost​ ​children​ ​-​ ​namely​ ​(n-k)!​ ​So​ ​we​ ​divide​ ​away​ ​the​ ​number​ ​of​ ​times​ ​we​ ​overcounted;​ ​hence
we​ ​divide​ ​n!​ ​by​ ​(n-k)!
Combinations

What​ ​happens​ ​if​ ​now​ ​we​ ​were​ ​putting​ ​some​ ​random​ ​object,​ ​say​ ​tennis​ ​balls,​ ​in​ ​the​ ​chairs?​ ​Let’s
pretend​ ​that​ ​we​ ​can’t​ ​tell​ ​the​ ​tennis​ ​balls​ ​apart.​ ​In​ ​other​ ​words,​ ​we​ ​only​ ​care​ ​about​ ​a​ ​selection
of​ ​chairs.​ ​How​ ​many​ ​different​ ​selections​ ​of​ ​k​ ​chairs​ ​are​ ​possible?

Well,​ ​we​ ​once​ ​again​ ​use​ ​the​ ​technique​ ​of​ ​overcounting!​ ​Let’s​ ​pretend​ ​all​ ​of​ ​my​ ​tennis​ ​balls​ ​are
different.​ ​Then,​ ​if​ ​we​ ​are​ ​putting​ ​k​ ​tennis​ ​balls​ ​in​ ​n​ ​chairs,​ ​there​ ​are​ ​P(n,k)​ ​=​ ​n!/(n-k)!​ ​ways​ ​to​ ​do
this.​ ​For​ ​each​ ​one​ ​of​ ​our​ ​selections,​ ​we​ ​then​ ​have​ ​k!​ ​different​ ​ways​ ​to​ ​arrange​ ​the​ ​balls!​ ​So​ ​it
turns​ ​out,​ ​for​ ​each​ ​selection​ ​of​ ​chairs,​ ​we​ ​overcounted​ ​k!​ ​times.​ ​It​ ​then​ ​makes​ ​sense​ ​to​ ​divide
away​ ​the​ ​k!.​ ​We​ ​call​ ​this​ ​a​ ​combination.

C(n,k)​ ​=​ ​P(n,k)/k!​ ​=​ ​n!​ ​/​ ​[​ ​(n-k)!​ ​k!​ ​]

Notice​ ​that​ ​the​ ​two​ ​numbers​ ​in​ ​the​ ​factorials​ ​in​ ​the​ ​denominator​ ​add​ ​to​ ​the​ ​one​ ​in​ ​the​ ​top.​ ​This
is​ ​no​ ​coincidence,​ ​and​ ​in​ ​fact,​ ​allows​ ​to​ ​state​ ​a​ ​very​ ​interesting​ ​fact:

Theorem.​​ ​C(n,k)​ ​=​ ​C(n,​ ​n-k).

Proof.​ ​C(n,k)​ ​=​ ​n!/[​ ​(n-k)!k!​ ​]​ ​=​ ​n!/​ ​[​ ​(n-(n-k))!(n-k)!​ ​]​ ​C(n,n-k).​ ​QED

Noting​ ​that​ ​k​ ​=​ ​n​ ​-​ ​(n-k).​ ​This​ ​should​ ​be​ ​obvious,​ ​since​ ​n-k​ ​is​ ​the​ ​number​ ​that​ ​adds​ ​to​ ​k​ ​to​ ​obtain
n.

Philosophically,​ ​however,​ ​there​ ​are​ ​stronger​ ​implications​ ​than​ ​just​ ​a​ ​formula​ ​-​ ​we​ ​see​ ​that​ ​the
formula​ ​does​ ​indeed​ ​agree​ ​with​ ​reality.​ ​Instead​ ​of​ ​looking​ ​at​ ​selections​ ​of​ ​chairs,​ ​we​ ​could​ ​also
count​ ​the​ ​number​ ​of​ ​ways​ ​that​ ​we​ ​don’t​ ​select​ ​the​ ​chairs​ ​-​ ​and​ ​it​ ​turns​ ​out​ ​that​ ​they’re​ ​the
same!

Putting​ ​it​ ​All​ ​Together...For​ ​Now.

We​ ​are​ ​now​ ​ready​ ​to​ ​try​ ​the​ ​problem​ ​stated​ ​at​ ​the​ ​beginning​ ​of​ ​this​ ​chapter.

Example​ ​1.​ ​Albert,​ ​Bernard,​ ​and​ ​Chelsea​ ​go​ ​to​ ​the​ ​movies​ ​with​ ​their​ ​“friend​ ​group,”​ ​which
consists​ ​of​ ​10​ ​people.​ ​The​ ​trouble​ ​is,​ ​Albert,​ ​Bernard,​ ​and​ ​Chelsea​ ​all​ ​mutually​ ​hate​ ​each​ ​other,
and​ ​no​ ​2​ ​of​ ​the​ ​3​ ​may​ ​sit​ ​next​ ​to​ ​each​ ​other.​ ​All​ ​of​ ​the​ ​“friends”​ ​are​ ​to​ ​sit​ ​in​ ​the​ ​same​ ​row.​ ​If
there​ ​are​ ​12​ ​seats​ ​in​ ​a​ ​row,​ ​how​ ​many​ ​possible​ ​seating​ ​arrangements​ ​are​ ​there?
There​ ​are​ ​many​ ​components​ ​to​ ​this​ ​problem​ ​-​ ​the​ ​important​ ​thing​ ​is​ ​to​ ​reduce​ ​it​ ​to​ ​a​ ​problem
where​ ​we​ ​only​ ​need​ ​to​ ​use​ ​tools​ ​that​ ​we​ ​already​ ​have.​ ​One​ ​thing​ ​we​ ​notice​ ​immediately​ ​is​ ​that
we​ ​can​ ​deal​ ​with​ ​the​ ​problem​ ​of​ ​the​ ​selection​ ​of​ ​the​ ​chairs​​ ​and​ ​the​ ​ordering​ ​of​ ​the​ ​friends
separately.​ ​If​ ​I​ ​first​ ​pick​ ​which​ ​chairs​ ​I’ll​ ​put​ ​the​ ​kids​ ​in,​ ​then​ ​order​ ​the​ ​friends​ ​(or​ ​vice​ ​versa),
then​ ​I​ ​will​ ​be​ ​able​ ​to​ ​obtain​ ​every​ ​possible​ ​arrangement​ ​this​ ​way,​ ​exactly​ ​once!​ ​In​ ​other​ ​words,
the​ ​selection​ ​of​ ​the​ ​chairs​ ​and​ ​the​ ​ordering​ ​of​ ​the​ ​friends​ ​are​ ​independent!​​ ​This​ ​will​ ​simplify
the​ ​problem​ ​drastically.

How​ ​many​ ​ways​ ​are​ ​there​ ​to​ ​select​ ​10​ ​chairs​ ​from​ ​12?​ ​Well…​ ​C(12,10)​ ​=​ ​12!/(10!2!)​ ​=​ ​66.

Now​ ​comes​ ​the​ ​hard​ ​part...ordering​ ​the​ ​friends.​ ​How​ ​do​ ​we​ ​make​ ​it​ ​so​ ​that​ ​none​ ​of​ ​Albert,
Bernard,​ ​and​ ​Chelsea​ ​sit​ ​next​ ​to​ ​each​ ​other?

The​ ​key​ ​insight​ ​is​ ​to​ ​see​ ​that​ ​we​ ​can​ ​separate​ ​the​ ​“good​ ​friends”​ ​from​ ​the​ ​“bad​ ​friends,”​ ​and
order​ ​them​ ​independently.​ ​In​ ​other​ ​words,​ ​let’s​ ​put​ ​the​ ​7​ ​“good​ ​friends”​ ​in​ ​a​ ​line.​ ​Where​ ​do​ ​we
insert​ ​the​ ​“bad​ ​friends?”​ ​We​ ​then​ ​look​ ​at​ ​the​ ​spaces​ ​between​ ​the​ ​7​ ​good​ ​friends!​​ ​Note​ ​that
there​ ​are​ ​exactly​ ​6​ ​spaces​ ​between​ ​the​ ​7​ ​good​ ​friends,​ ​and​ ​1​ ​space​ ​before​ ​and​ ​1​ ​space​ ​after​ ​to
insert​ ​the​ ​bad​ ​friends,​ ​making​ ​8​ ​spaces​ ​total.​ ​Each​ ​one​ ​of​ ​these​ ​spaces​ ​can​ ​only​ ​have​ ​1​ ​bad
friend!​ ​If​ ​we​ ​go​ ​by​ ​this​ ​arrangement,​ ​none​ ​of​ ​the​ ​three​ ​bad​ ​friends​ ​will​ ​ever​ ​have​ ​to​ ​sit​ ​next​ ​to
each​ ​other.

How​ ​many​ ​ways​ ​can​ ​I​ ​choose​ ​3​ ​of​ ​these​ ​8​ ​spaces​ ​for​ ​the​ ​bad​ ​friends?​ ​C(8,3).​ ​How​ ​many​ ​ways
can​ ​I​ ​order​ ​the​ ​7​ ​good​ ​friends?​ ​There​ ​are​ ​7!​ ​ways.​ ​How​ ​many​ ​ways​ ​can​ ​I​ ​order​ ​the​ ​3​ ​bad
friends?​ ​There​ ​are​ ​3!​ ​ways.​ ​Put​ ​it​ ​all​ ​together,​ ​and​ ​there​ ​are​ ​C(8,3)*​ ​7!​ ​*​ ​3!​ ​ways.

So​ ​the​ ​answer​ ​to​ ​the​ ​problem​ ​is​ ​C(12,10)​ ​*​ ​C(8,3)​ ​*​ ​7!​ ​*​ ​3!​ ​=​ ​111,767,040​ ​ways.

Here​ ​are​ ​a​ ​few​ ​more​ ​examples​ ​that​ ​illustrate​ ​some​ ​basic​ ​counting​ ​techniques.

Example​ ​3.​ ​There​ ​are​ ​n​ ​people​ ​in​ ​a​ ​room.​ ​If​ ​everyone​ ​shook​ ​everyone​ ​else’s​ ​hand,​ ​how​ ​many
handshakes​ ​took​ ​place?

This​ ​is​ ​an​ ​elementary​ ​problem​ ​in​ ​graph​ ​theory​ ​-​ ​namely,​ ​if​ ​we​ ​draw​ ​n​ ​different​ ​“dots”​ ​(vertices),
and​ ​connect​ ​every​ ​dot​ ​to​ ​every​ ​other​ ​dot​ ​(edges),​ ​how​ ​many​ ​lines​ ​(edges)​ ​did​ ​we​ ​draw?

Let’s​ ​do​ ​it​ ​this​ ​way​ ​-​ ​let’s​ ​overcount​ ​and​ ​then​ ​divide​ ​out.​ ​Consider​ ​ordered​ ​pairs​ ​that​ ​look​ ​like
this:​ ​(person​ ​1,​ ​person​ ​2).​ ​Well,​ ​no​ ​one​ ​shakes​ ​their​ ​own​ ​hand,​ ​and​ ​so​ ​each​ ​person​ ​shakes​ ​n-1
hands,​ ​so​ ​there​ ​are​ ​n-1​ ​such​ ​pairs​ ​for​ ​each​ ​person.​ ​This​ ​makes​ ​a​ ​total​ ​of​ ​n*(n-1)​ ​pairs.​ ​But​ ​wait
a​ ​minute!​ ​(Person​ ​A,​ ​Person​ ​B)​ ​and​ ​(Person​ ​B,​ ​Person​ ​A)​ ​are​ ​actually​ ​just​ ​the​ ​same​ ​handshake!
So​ ​we​ ​divide​ ​by​ ​2​ ​to​ ​obtain​ ​the​ ​real​ ​number​ ​of​ ​handshakes:​ ​namely,​ ​n*(n-1)/2​.

Notice​ ​that​ ​this​ ​number​ ​is​ ​precisely​ ​C(n,2).​ ​This​ ​is​ ​no​ ​coincidence​ ​-​ ​the​ ​number​ ​of​ ​handshakes
that​ ​took​ ​place​ ​is​ ​the​ ​same​ ​as​ ​the​ ​number​ ​of​ ​ways​ ​to​ ​select​ ​2​ ​things​ ​from​ ​n​ ​things!​ ​We​ ​select​ ​2
distinguishable​ ​things​ ​and​ ​have​ ​them​ ​do​ ​a​ ​handshake;​ ​C(n,2)​ ​counts​ ​the​ ​number​ ​of​ ​ways​ ​to​ ​do
this.

Example​ ​4.​ ​On​ ​the​ ​cartesian​ ​coordinate​ ​plane,​ ​start​ ​at​ ​the​ ​point​ ​(0,0).​ ​We​ ​play​ ​a​ ​game​ ​where
during​ ​each​ ​turn,​ ​you​ ​may​ ​add​ ​1​ ​to​ ​the​ ​x-coordinate,​ ​or​ ​you​ ​may​ ​add​ ​1​ ​to​ ​the​ ​y-coordinate.
These​ ​are​ ​the​ ​only​ ​legal​ ​moves.​ ​How​ ​many​ ​paths​ ​can​ ​you​ ​take​ ​to​ ​reach​ ​(m,n),​ ​where​ ​m,n​ ​are
both​ ​positive​ ​integers?​ ​(​ ​If​ ​we​ ​were​ ​attempting​ ​to​ ​reach​ ​(2,1),​ ​a​ ​sample​ ​path​ ​would​ ​be​ ​(0,0)​ ​->
(1,0)​ ​->​ ​(1,1)​ ​->​ ​(2,1)​ ​)

If​ ​we​ ​denote​ ​by​ ​R​ ​the​ ​action​ ​of​ ​adding​ ​1​ ​to​ ​the​ ​x-coordinate,​ ​and​ ​U​ ​the​ ​action​ ​of​ ​adding​ ​1​ ​to​ ​the
y-coordinate,​ ​then​ ​it​ ​turns​ ​out​ ​that​ ​we​ ​may​ ​just​ ​count​ ​the​ ​number​ ​of​ ​different​ ​sequences​ ​that
look​ ​something​ ​like:

RRRUURRURURURURURUR…

How​ ​many​ ​things​ ​are​ ​there?​ ​Well,​ ​it​ ​doesn’t​ ​matter​ ​what​ ​order​ ​it​ ​happens​ ​in;​ ​x​ ​and​ ​y​ ​are
independent,​ ​so​ ​as​ ​long​ ​as​ ​there​ ​are​ ​m​ ​copies​ ​of​ ​R​ ​on​ ​the​ ​list,​ ​and​ ​n​ ​copies​ ​of​ ​U​ ​on​ ​the​ ​list,​ ​we’ll
reach​ ​(m,n).

Let’s​ ​count​ ​the​ ​lists​ ​this​ ​way​ ​-​ ​notice​ ​that​ ​our​ ​list​ ​will​ ​be​ ​of​ ​length​ ​m+n​.​ ​(why?)​ ​Of​ ​that​ ​list,​ ​pick
m​ ​different​ ​spots​ ​for​ ​the​ ​R’s.​ ​The​ ​rest​ ​must​ ​be​ ​U’s,​ ​so​ ​no​ ​need​ ​to​ ​count​ ​those.​ ​Hence,​ ​there​ ​are
C(m+n,​ ​m)​ ​different​ ​ways​ ​to​ ​get​ ​to​ ​(m,n).

Sometimes,​ ​it​ ​helps​ ​to​ ​shift​ ​the​ ​perspective​ ​of​ ​the​ ​problem​ ​-​ ​instead​ ​of​ ​counting​ ​from​ ​one
“angle,”​ ​perhaps​ ​shifting​ ​the​ ​counting​ ​method,​ ​or​ ​the​ ​objects​ ​being​ ​counted,​ ​is​ ​beneficial.​ ​Here
is​ ​an​ ​elementary​ ​problem​ ​from​ ​set​ ​theory:

Example​ ​5.​ ​If​ ​S​ ​is​ ​a​ ​set​ ​with​ ​n​ ​elements,​ ​how​ ​many​ ​subsets​ ​are​ ​there​ ​of​ ​S?​ ​(A​ ​subset​ ​of​ ​S​ ​is​ ​a​ ​set
where​ ​every​ ​element​ ​of​ ​the​ ​subset​ ​is​ ​also​ ​an​ ​element​ ​of​ ​S.)

To​ ​make​ ​things​ ​clear,​ ​let’s​ ​list​ ​all​ ​of​ ​the​ ​subsets​ ​of​ ​the​ ​set​ ​{1,2,3}.​ ​Those​ ​are:​ ​empty​ ​set​ ​(we​ ​pick
nothing),​ ​{1},​ ​{2},​ ​{3},​ ​{1,2},​ ​{1,3},​ ​{2,3},​ ​{1,2,3}.​ ​There​ ​are​ ​8​ ​subsets​ ​of​ ​{1,2,3}.
One​ ​way​ ​to​ ​count​ ​the​ ​number​ ​of​ ​subsets​ ​is​ ​to​ ​divide​ ​them​ ​up​ ​by​ ​set​ ​size​ ​(cardinality)!​ ​So​ ​for
{1,2,3},​ ​there​ ​is​ ​1​ ​set​ ​with​ ​0​ ​elements​ ​(the​ ​empty​ ​set),​ ​3​ ​sets​ ​with​ ​1​ ​element,​ ​3​ ​sets​ ​with​ ​two
elements,​ ​and​ ​1​ ​set​ ​with​ ​3​ ​elements.​ ​(If​ ​you​ ​recognize​ ​these​ ​numbers​ ​are​ ​the​ ​third​ ​row​ ​of
Pascal’s​ ​triangle,​ ​then​ ​you​ ​are​ ​following​ ​along​ ​very​ ​nicely)

For​ ​a​ ​set​ ​with​ ​3​ ​elements:


-There​ ​are​ ​C(3,0)​ ​sets​ ​of​ ​0​ ​elements.
-There​ ​are​ ​C(3,1)​ ​sets​ ​with​ ​1​ ​elements.
-There​ ​are​ ​C(3,2)​ ​sets​ ​with​ ​2​ ​elements.
-There​ ​are​ ​C(3,3)​ ​sets​ ​with​ ​3​ ​elements.

So​ ​it​ ​turns​ ​out,​ ​the​ ​number​ ​of​ ​subsets​ ​is​ ​these​ ​numbers​ ​added​ ​together:

C(3,0)​ ​+​ ​C(3,1)​ ​+​ ​C(3,2)​ ​+​ ​C(3,3)​ ​=​ ​8!​ ​It​ ​then​ ​follows​ ​that​ ​for​ ​a​ ​set​ ​of​ ​n​ ​elements,​ ​the​ ​number​ ​of
subsets​ ​is​ ​equal​ ​to

C(n,0)​ ​+​ ​C(n,1)​ ​+​ ​C(n,2)​ ​+​ ​…​ ​+​ ​C(n,n).​ ​Notice​ ​that​ ​C(n,0)​ ​=​ ​C(n,n)​ ​=​ ​1;​ ​this​ ​makes​ ​sense
philosophically.​ ​How​ ​many​ ​ways​ ​are​ ​there​ ​to​ ​pick​ ​n​ ​objects​ ​from​ ​n?​ ​Only​ ​one​ ​way​ ​-​ ​pick​ ​all​ ​of
them.​ ​How​ ​many​ ​ways​ ​are​ ​there​ ​to​ ​pick​ ​0​ ​objects?​ ​1.​ ​You​ ​don’t​ ​pick​ ​anything.

Unfortunately,​ ​listing​ ​the​ ​sum​ ​of​ ​combinations​ ​(which​ ​is​ ​equal​ ​to​ ​the​ ​sum​ ​of​ ​the​ ​n​th​ ​row​ ​of
Pascal’s​ ​Triangle),​ ​doesn’t​ ​quite​ ​help​ ​us​ ​achieve​ ​a​ ​numerical​ ​answer.

However,​ ​reframing​ ​the​ ​problem​ ​does!​ ​What​ ​if,​ ​we​ ​assigned​ ​to​ ​each​ ​subset,​ ​an​ ​n-tuple​ ​(list​ ​of
length​ ​n)​ ​that​ ​looks​ ​something​ ​like:​ ​(0,1,1,0,1,0,1,1,0,...,1),​ ​where​ ​the​ ​k​th​ ​entry​ ​is​ ​1​ ​if​ ​k​ ​is​ ​in​ ​the
subset,​ ​and​ ​0​ ​if​ ​not?​ ​Then,​ ​for​ ​each​ ​entry,​ ​there​ ​are​ ​2​ ​possibilities​ ​-​ ​0​ ​and​ ​1,​ ​and​ ​for​ ​n​ ​entries,
there​ ​are​ ​2*2*2*...*2​ ​=​ ​2n​​ ​ ​possibilities!

So​ ​it​ ​turns​ ​out​ ​that​ ​C(n,0)​ ​+​ ​C(n,1)​ ​+​ ​…​ ​+​ ​C(n,n)​ ​=​ ​2n​​ .​ ​(Remark:​ ​Prove​ ​this​ ​with​ ​the​ ​binomial
theorem!)

In​ ​this​ ​problem,​ ​we​ ​used​ ​an​ ​idea​ ​called​ ​the​ ​Sum​ ​Principle​​ ​-​ ​in​ ​other​ ​words,​ ​you​ ​can​ ​break​ ​the
total​ ​number​ ​of​ ​possibilities​ ​down,​ ​calculate​ ​them​ ​independently,​ ​and​ ​then​ ​add​ ​them​ ​all​ ​up.​ ​A
formal​ ​definition​ ​will​ ​be​ ​given​ ​in​ ​the​ ​next​ ​section.

Sometimes​ ​it’s​ ​best​ ​to​ ​count​ ​everything,​ ​and​ ​instead​ ​of​ ​counting​ ​what​ ​you​ ​want​,​ ​count​ ​what
you​ ​don’t​ ​want​ ​and​ ​subtract​ ​it​ ​from​ ​the​ ​total.​ ​This​ ​is​ ​called​ ​counting​ ​the​ ​complement.
Example​ ​6.​ ​There​ ​are​ ​5​ ​couples,​ ​to​ ​be​ ​seated​ ​in​ ​a​ ​row​ ​of​ ​10​ ​chairs.​ ​(a)​ ​How​ ​many​ ​seating
arrangements​ ​are​ ​there​ ​where​ ​none​ ​of​ ​the​ ​couples​ ​are​ ​together?​ ​(b)​ ​How​ ​many​ ​seating
arrangements​ ​are​ ​there​ ​where​ ​all​ ​of​ ​the​ ​couples​ ​are​ ​together?

As​ ​hinted​ ​from​ ​the​ ​advice​ ​just​ ​before​ ​the​ ​problem,​ ​it​ ​makes​ ​sense​ ​to​ ​count​ ​all​ ​of​ ​the​ ​possible
seating​ ​arrangements,​ ​and​ ​then​ ​to​ ​count​ ​the​ ​number​ ​of​ ​ways​ ​where​ ​at​ ​least​ ​one​ ​of​ ​the​ ​couples
are​ ​together.​ ​This​ ​might​ ​actually​ ​seem​ ​more​ ​difficult​ ​than​ ​counting​ ​the​ ​number​ ​of​ ​ways​ ​none​ ​of
the​ ​couples​ ​are​ ​together,​ ​but​ ​as​ ​it​ ​turns​ ​out,​ ​there​ ​is​ ​a​ ​very​ ​powerful​ ​tool​ ​that​ ​awaits​ ​us.

There​ ​are​ ​10!​ ​ways​ ​to​ ​order​ ​the​ ​10​ ​people.​ ​Now​ ​we​ ​just​ ​have​ ​to​ ​find​ ​out​ ​how​ ​many​ ​ways​ ​at
least​ ​one​ ​of​ ​the​ ​couples​ ​is​ ​together!​ ​We​ ​write​ ​the​ ​equation:

#(None​ ​of​ ​the​ ​couples​ ​are​ ​together)​ ​=​ ​10!​ ​-​ ​#(At​ ​least​ ​one​ ​of​ ​the​ ​couples​ ​is​ ​together)

We​ ​will​ ​defer​ ​solving​ ​this​ ​problem​ ​until​ ​we​ ​have​ ​an​ ​important​ ​tool​ ​-​ ​the​ ​Inclusion-Exclusion
principle.

Part​ ​(b)​ ​can​ ​seem​ ​very​ ​difficult,​ ​but​ ​if​ ​we​ ​pretend​ ​each​ ​couple​ ​is​ ​a​ ​singular​ ​unit,​ ​the​ ​problem
becomes​ ​much​ ​simpler.​ ​We​ ​will​ ​first​ ​order​ ​the​ ​couples,​ ​then​ ​order​ ​the​ ​members​ ​of​ ​the​ ​couple.

There​ ​are​ ​5!​ ​ways​ ​to​ ​arrange​ ​the​ ​couples.​ ​For​ ​each​ ​couple,​ ​there​ ​are​ ​two​ ​ways​ ​to​ ​arrange​ ​them;
(Person​ ​A,​ ​Person​ ​B)​ ​and​ ​(Person​ ​B,​ ​Person​ ​A).​ ​Since​ ​there​ ​are​ ​5​ ​couples,​ ​there​ ​are​ ​2*2*2*2*2​ ​=
32​ ​ways​ ​for​ ​the​ ​members​ ​of​ ​the​ ​couple​ ​to​ ​arrange​ ​themselves,​ ​given​ ​an​ ​arrangement​ ​of​ ​the
couples.​ ​So​ ​the​ ​total​ ​is​​ ​25​​ ​ ​*​ ​5!​ ​=​ ​3840.

Exercises

1. In​ ​California,​ ​license​ ​plates​ ​begin​ ​with​ ​a​ ​number,​ ​followed​ ​by​ ​3​ ​letters,​ ​and​ ​then​ ​another
number.​ ​How​ ​many​ ​license​ ​plates​ ​are​ ​possible​ ​if:
a. There​ ​are​ ​no​ ​restrictions​ ​on​ ​the​ ​letters​ ​or​ ​the​ ​numbers
b. The​ ​numbers​ ​“666”​ ​and​ ​“911”​ ​are​ ​prohibited
c. License​ ​plates​ ​must​ ​begin​ ​with​ ​7​ ​or​ ​8
d. No​ ​two​ ​of​ ​the​ ​same​ ​letters​ ​or​ ​numbers​ ​can​ ​be​ ​used
e. One​ ​of​ ​the​ ​letters​ ​used​ ​must​ ​appear​ ​twice,​ ​and​ ​each​ ​number​ ​that​ ​is​ ​used​ ​must
show​ ​up​ ​exactly​ ​twice
f. 9​ ​is​ ​on​ ​the​ ​license​ ​plate​ ​if​ ​and​ ​only​ ​if​ ​Z​ ​is​ ​also​ ​on​ ​the​ ​license​ ​plate
2. There​ ​are​ ​20​ ​angsty​ ​businesspeople​ ​in​ ​a​ ​meeting,​ ​and​ ​they​ ​are​ ​to​ ​make​ ​a​ ​committee​ ​of
6​ ​people.​ ​There​ ​are​ ​10​ ​men,​ ​and​ ​10​ ​women​ ​in​ ​this​ ​meeting.​ ​How​ ​many​ ​committees​ ​can
be​ ​made​ ​if:
a. There​ ​are​ ​no​ ​restrictions
b. There​ ​must​ ​be​ ​an​ ​equal​ ​number​ ​of​ ​men​ ​and​ ​women​ ​in​ ​the​ ​committee
3. There​ ​are​ ​40​ ​antennas;​ ​15​ ​of​ ​them​ ​are​ ​broken.​ ​All​ ​of​ ​the​ ​antennas​ ​are​ ​to​ ​be​ ​arranged​ ​in
a​ ​line.​ ​How​ ​many​ ​possible​ ​arrangements​ ​are​ ​there​ ​where​ ​none​ ​of​ ​the​ ​broken​ ​antennas
are​ ​next​ ​to​ ​each​ ​other?​ ​(Hint:​ ​Consult​ ​example​ ​1)
4. At​ ​Sam’s​ ​Donuts,​ ​there​ ​are​ ​three​ ​different​ ​flavors​ ​of​ ​donuts​ ​-​ ​glazed,​ ​sprinkled,​ ​and
jelly-filled.​ ​How​ ​many​ ​boxes​ ​of​ ​12​ ​donuts​ ​are​ ​possible?​ ​(If​ ​two​ ​donuts​ ​of​ ​the​ ​same​ ​kind
are​ ​indistinguishable)​ ​You​ ​may​ ​have​ ​boxes​ ​that​ ​consist​ ​of​ ​12​ ​donuts​ ​of​ ​1​ ​flavor,​ ​or​ ​boxes
that​ ​have​ ​6​ ​of​ ​one​ ​flavor,​ ​4​ ​of​ ​another,​ ​and​ ​2​ ​of​ ​the​ ​final​ ​flavor,​ ​and​ ​so​ ​on.​ ​(Hint:​ ​Create
a​ ​line​ ​of​ ​donuts,​ ​and​ ​then​ ​put​ ​two​ ​dividers​ ​in​ ​between​ ​them,​ ​separating​ ​them​ ​into​ ​flavor
categories.​ ​How​ ​many​ ​different​ ​ways​ ​can​ ​you​ ​do​ ​this?​ ​This​ ​is​ ​called​ ​the​ ​“stars​ ​and​ ​bars”
method.)
5. There​ ​are​ ​k​ ​distinguishable​ ​balls​ ​to​ ​be​ ​placed​ ​into​ ​n​ ​distinguishable​ ​baskets.​ ​How​ ​many
ways​ ​can​ ​you​ ​do​ ​this​ ​if:
a. Only​ ​one​ ​ball​ ​can​ ​go​ ​into​ ​each​ ​basket
b. Any​ ​number​ ​of​ ​balls​ ​can​ ​go​ ​into​ ​any​ ​basket
6. There​ ​are​ ​10​ ​couples​ ​at​ ​a​ ​wedding,​ ​to​ ​be​ ​seated​ ​in​ ​a​ ​row​ ​of​ ​20​ ​seats.​ ​How​ ​many​ ​seating
arrangements​ ​are​ ​there​ ​where​ ​at​ ​least​ ​one​ ​of​ ​the​ ​couples​ ​is​ ​broken​ ​up?
7. How​ ​many​ ​functions​ ​are​ ​there​ ​that​ ​take​ ​an​ ​input​ ​from​ ​{1,2,3,4,5,6,7,8,9}​ ​and​ ​return​ ​an
output​ ​from​ ​{a,b,c,d,e}?
8. Poker​ ​Hands​:​ ​A​ ​deck​ ​of​ ​cards​ ​has​ ​52​ ​cards.​ ​Each​ ​card​ ​has​ ​a​ ​suit​ ​and​ ​a​ ​value.​ ​The
different​ ​values​ ​are​ ​Ace,​ ​2,​ ​3,​ ​4,​ ​5,​ ​6,​ ​7,​ ​8,​ ​9,​ ​10,​ ​Jack,​ ​Queen,​ ​King.​ ​The​ ​four​ ​suits​ ​are
Diamonds,​ ​Clubs,​ ​Hearts,​ ​and​ ​Spades.
a. If​ ​you​ ​draw​ ​five​ ​cards​ ​from​ ​the​ ​deck,​ ​how​ ​many​ ​different​ ​possible​ ​hands​ ​are
there?
b. A​ ​full​ ​house​ ​is​ ​a​ ​five​ ​card​ ​hand​ ​where​ ​there​ ​are​ ​3​ ​cards​ ​of​ ​one​ ​value,​ ​and​ ​two​ ​of​ ​a
different​ ​value.​ ​How​ ​many​ ​full​ ​houses​ ​are​ ​there?​ ​(For​ ​example,​ ​KKK77​ ​is​ ​a​ ​full
house,​ ​where​ ​the​ ​kings​ ​are​ ​of​ ​any​ ​3​ ​of​ ​the​ ​4​ ​suits,​ ​and​ ​the​ ​7’s​ ​are​ ​of​ ​any​ ​2​ ​of​ ​the
4​ ​suits)
c. A​ ​straight​ ​is​ ​a​ ​five​ ​card​ ​hand​ ​where​ ​the​ ​values​ ​of​ ​the​ ​cards​ ​are​ ​sequential.​ ​For
instance,​ ​A2345​ ​is​ ​a​ ​straight,​ ​and​ ​10JQKA​ ​is​ ​a​ ​straight,​ ​but​ ​23457​ ​is​ ​not​ ​a​ ​straight.
How​ ​many​ ​straights​ ​are​ ​there?
d. A​ ​straight​ ​flush​ ​is​ ​a​ ​straight​ ​where​ ​all​ ​of​ ​the​ ​cards​ ​are​ ​of​ ​the​ ​same​ ​suit.​ ​How
many​ ​straight​ ​flushes​ ​are​ ​there?
e. A​ ​two​ ​pair​ ​is​ ​exactly​ ​what​ ​it​ ​sounds​ ​like​ ​-​ ​there​ ​are​ ​two​ ​pairs​ ​of​ ​cards​ ​that​ ​are​ ​of
the​ ​same​ ​value,​ ​but​ ​is​ ​not​ ​a​ ​full​ ​house.​ ​How​ ​many​ ​two​ ​pairs​ ​are​ ​there?
9. A​ ​classroom​ ​has​ ​40​ ​students​ ​(20​ ​girls​ ​and​ ​20​ ​boys),​ ​and​ ​20​ ​desks​ ​-​ ​two​ ​to​ ​a​ ​desk.​ ​How
many​ ​seating​ ​arrangements​ ​are​ ​there​ ​if​ ​every​ ​boy​ ​must​ ​sit​ ​next​ ​to​ ​a​ ​girl?​ ​If​ ​girls​ ​must​ ​sit
with​ ​girls​ ​and​ ​boys​ ​must​ ​sit​ ​with​ ​boys?

Anda mungkin juga menyukai