06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

“mcs” — 2017/3/3 — 11:21 — page 600 — #608<br />

600<br />

Chapter 15<br />

Cardinality Rules<br />

15.2.3 The Sum Rule<br />

Bart allocates his little sister Lisa a quota of 20 crabby days, 40 irritable days,<br />

and 60 generally surly days. On how many days can Lisa be out-of-sorts one way<br />

or another? Let set C be her crabby days, I be her irritable days, and S be the<br />

generally surly. In these terms, the answer to the question is jC [ I [ Sj. Now<br />

assuming that she is permitted at most one bad quality each day, the size of this<br />

union of sets is given by the Sum Rule:<br />

Rule 15.2.2 (Sum Rule). If A 1 ; A 2 ; : : : ; A n are disjoint sets, then:<br />

jA 1 [ A 2 [ : : : [ A n j D jA 1 j C jA 2 j C : : : C jA n j<br />

Thus, according to Bart’s budget, Lisa can be out-of-sorts <strong>for</strong>:<br />

jC [ I [ Sj D jC j C jI j C jSj<br />

D 20 C 40 C 60<br />

D 120 days<br />

Notice that the Sum Rule holds only <strong>for</strong> a union of disjoint sets. Finding the size<br />

of a union of overlapping sets is a more complicated problem that we’ll take up in<br />

Section 15.9.<br />

15.2.4 Counting Passwords<br />

Few counting problems can be solved with a single rule. More often, a solution is<br />

a flurry of sums, products, bijections, and other methods.<br />

For solving problems involving passwords, telephone numbers, and license plates,<br />

the sum and product rules are useful together. For example, on a certain computer<br />

system, a valid password is a sequence of between six and eight symbols. The first<br />

symbol must be a letter (which can be lowercase or uppercase), and the remaining<br />

symbols must be either letters or digits. How many different passwords are<br />

possible?<br />

Let’s define two sets, corresponding to valid symbols in the first and subsequent<br />

positions in the password.<br />

F D fa; b; : : : ; z; A; B; : : : ; Zg<br />

S D fa; b; : : : ; z; A; B; : : : ; Z; 0; 1; : : : ; 9g<br />

In these terms, the set of all possible passwords is: 1<br />

1 The notation S 5 means S S S S S.<br />

.F S 5 / [ .F S 6 / [ .F S 7 /

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!