The Rules of Sum and Product
Fundamental
Principles of
Counting
Foumeration, or counting, may strike one as an obvious process that a student learns
when first studying arithmetic. But then, it seems, very litle attention is paid to further
development in counting as the student turns to "more difficult” areas in mathematics, such
as algebra, geometry, trigonometry, and calculus. Consequently, this first chapter should
provide some waming about the seriousness and difficulty of “mere” counting,
‘Enumeration does not end with arithmetic. It also has applications in such areas as coding
theory, probability and statistics, and in the analysis of algorithms. Later chapters will offer
some specific examples of these applications.
As we enter this fascinating field of mathematics, we shall come upon many problems that
are very simple to state but somewhat “sticky” tosolve. Thus, be sure to learn and understand
the basie formulas — but do nor rely on them too heavily. For without an analysis of each
problem, « mere knoviledge of formulas is next to useless. Instead, welcome the challenge
to solve unusual problems or those that are different from problems you have encountered
in the past. Seek solutions based on your own scrutiny, regardless of whether it reproduces,
‘what the author provides. There are often several ways to solve a given problem,
u
‘Our study of discrete and combinatorial mathematics begins with two basic principles of
‘counting: the rules of sum and product. The statements and initial applications of these
rules appear quite simple. In analyzing more complicated problems, one is often able to
break down such problems into parts that can be solved using these basic principles. We
\want to develop the ability to “decompose” such problems and piece together our partial
solutions in order to arrive at the final answer. A good way to do this is o analyze and solve
many diverse enumeration problems, taking note of the principles being used. This is the
‘approach we shall follow here
‘Our first principle of counting can be stated as follows:
RRR Seman tn prt in yw nd hn
‘be performed in n ways, and the two tasks cannot be performed simultaneously, then
_ potfoimnisg either task can be accomplished in any one of m +n ways.4 ‘Chapter Fundamental Principles of Courting
EXAMPLE 1.1
EXAMPLE 12.
EXAMPLE LO |
EXAMPLE 1.5
EXAMPLE 1.6
Note that when we say that a particular occurrence, such as a frst task, can come about in m
‘ways, these m ways are assumed to be distinct, unless a statement is made to the contrary.
‘This will be tuo throughout the entre text.
Acollege library has 40 textbooks on sociology and $0 textbooks dealing with anthropology,
By the rule of sum, a student at this college can sclect among 40 + 50 = 90 textbooks in
order to learn more sbout one or the other of these two subjects,
‘The rule can be extended beyond two tasks as long as no pair of tasks can occur simultane-
ously. For instance, a computer science instructor who has, say, seven different introductory
books each on C+, Java, and Perl can recommend any one of these 21 books to a student
Who is interested in learning a first programming language.
‘The computer science instructor of Example 1.2 has two colleagues. One of these col
leagues has three textbooks on the analysis of algorithms, and the other has five such
textbooks. If denotes the maximum number of different books on this topic that this
instructor can borrow from them, then $
0,
Before we proceed any further, let us try to get @ somewhat better appreciation for how
fast n! grows, We can calculate that 10! = 3,628,800, and it just so happens that this is
‘exactly the number of seconds in six weeks, Consequently, 11! exceeds the number of
seconds in one year, 12! exceeds the number in 12 years, and 13! surpasses the number of
seconds in a century[EXAMPLE 1:10
12. Permutations 7
If we make use of the factorial notation, the answer in Example 1,9 can be expressed in
the following more compact form:
10X9X 8X76 = 10X9X 8X7 6x SRSXSNIXT _ 10!
SxaK3RIx1
Given a collection of n distinct objects, any (linear) arrangement of these objects is called
permutation of the collection,
‘Starting with the letters a,b, ¢, there are six ways to arrange, or permute, all ofthe letters:
abe, acb, bac, bea, cab, cba. If we are interested in arranging only two of the leters at a
time, there are six such size-2 permutations: ab, ba, ac, ca, Be, cb.
If there are m distinct objects and r is an integer, with
product, the number of permutations of size r forthe m object is
Pan X MX M@-YX--X Garth)
then by the nile of
ua md a
eon — pain pron peste
= @n-1n-2)- ar one
MN —2) EDX TRE
eee
or
Forr = 0, P(r, 0) = L = nl/(n ~0)!.s0 Pn, r) = n'/(n ~ r)t holds forall 0 3
fone finds that P(r, — 3) = nlf — (1 ~3)} = nlf3t = (y(n = Don = 2) + SYA.
‘The number of permutations of size r, where 0 0,
‘The number of permutations of the letters in the word COMPUTER is 8, IF only five ofthe
letters are used, the number of permutations (of size 5) is P(8, 5) = 81/(8 ~ 5)! = 81/3! =
(6720, If repetitions of letters are allowed, the number of possible I2-letter sequences is
8! = 6.872 x 1010.1
Unlike Example 1.10, the number of (lineat) arrangements of the four letters in BALL is
12, not 4! (= 24). The reason is that we do not have four distinct letters to arrange. To get
the 12 arrangements, we cam list them as in Table 1.1(a).
‘rhe symbol "=" is read “is approximately equal a8 Chapter 1 Fundamental Prncpes of Counting
Table 1
Ifthe two L's are distinguished as L,, La, then we can use our previous ideus on per-
mutations of distinct objects; with the four distinct symbols B, A, Li, L2, we have 4! = 24
permutations, These are listed in Table 1.1(b). Table 1.1 reveals that for each arrangement
in which the L's are indistinguishable there corresponds a pair of permutations with distinct
L's. Consequently,
2 (Number of arrangements of the leters B, A,
)
[Number of permutations of the symbols B, A, L), La),
‘and the answer to the original problem of finding all the arrangements of the four leters in
BALLis 41/2 = 12.
Using the idea developed in Example 1.11, we now consider the arrangements of all nine
letters in DATABASES.
‘There are 31 = 6 arrangements with the A's distinguished for each arrangement in
‘which the A’s are not distinguished. For example, DA;TA:BA,SES, DA TASBA,SES,
DA;TA;BAsSES, DA;TA3BA,SES, DAyTA; BASES, and DA;TA:BA, SES all correspond
to DATABASES, when we remove the subscripts on the A's. In addition, to the szrange-
ment DA;TA:BA:SES there corresponds the pair of permutations DATA BAx$iBS> and
DAyTA:BAxS:ES}, when the S's are distinguished. Consequently,
(2(3) (Number of arrangements of the leters in DATABASES)
(Number of permutations of the symbols D, A}, T, As, B, As,
E82).
so the number of arrangements of the nine letiers in DATABASES is 91/(2! 3!) ~ 30,240,
Before stating a general principle for arrangements with repeated symbols, note thatin our
prior two examples we solved a new type of problem by relating ito previous enumeration
principles. This practice is common in mathematics in general, and often occurs in the
derivations of discrete and combinatorial formulas,EXAMPLE 113 |
sapie
EXAMPLE 114 |
12. Permutations 9
Tfthere are objects with m; indistinguishable objects of a first type, m2 indistinguishable
objects ofa second type, ... and indisingishable objects of an rth type, where
bina bobo = n.then here are ———— "(linea arrangements ofthe given
objec i
‘The MASSASAUGA is a brown and white venomous snake indigenous to North America
Arranging all of the leters in MASSASAUGA, we find that there are
10
marian * 75200
possible arrangements. Among these are
2
= 840
anit
in which al four A's are together. To get this last result, we considered all arrangements of
the seven symbols AAAA (one symbol), §, 8. 8, M, U, G.
Determine the number of (staircase) paths in the xy-plane from (2, 1) t0 (7, 4), where each,
such path is made up of individual steps going one unit to the right (R) or one unit upward
(U). The blue Tines in Fig. 1.1 show to of these paths
@
Figure 11
Beneath each path in Fig. 1.1 we have listed the individual steps. For example, in part
(@) the list R, U,R, R, U, R, R, U indicates that starting at the point (2, 1), we first move
‘one unit to the right [0 (3, 1)J, then one unit upward [to G3, 2)} followed by two units to
the right to (5, 2)], and so on, until we reach the point (7, 4). The path consists of five R's
for moves to the right and three U's For moves upward,
The path in part (b) of the figure is also made up of five R’s and three U's. In general,
the overall tip from (2, 1) 10 (7, 4) requites 7 ~ 2 = 5 horizontal moves to the right and
4~1=3 vertical moves upward. Consequently, each path corresponds to a list of five
R's and three U's, and the solution for the number of paths emerges as the number of
arrangements of the five R’s and three Us, which is 81/(513") « 56.Chapter 1 Fundamental Principles of Counting
EXAMPLE 1.15
EXAMPLE 1.16
‘We now do something abit more abstract and prove that if and k ae postive integers with
n= 2k, then n!/2 isan integer. Because our argument relies on counting, itis an example
of a combinatorial proof.
Consider then symbols x),X).12, 42, «+ th, Xk: The numberof waysin which we can
anmange all ofthese
2k symbols is an integer that equals
Finally, we wil apply what has been developed so fart a situation
ments are no longer linear.
which the arrange-
If'six people, designated as A,B, ...,F,are seated about around table, how many different
circular arrangements are possible, if arrangements are considered the same when one can
be obtained from the other by rotation? [In Fig. 1.2, arrangements (a) and (b) are considered
identical, whereas (b), (€), and (0) are three distinct arrangements}
A c i] A 2
» e |r ois ole a
c ele ale cfr G
@ @
@ we) © ®
Figure 1.2
We shall try to relate this problem to previous ones we have already encountered, Con-
sider Figs. 1.3(a) and (b). Starting at the top of the circle and moving clockwise, we list
the distinct linear arrangements ABEFCD and CDABER, which correspond to the same
circular arrangement. In addition to these two, four other linear arrangements —BEFCDA,
DABEEC, EFCDAB, and FCDABE are found to correspond to the same circular ar-
rangement as in (a) or (b). So inasmuch as each circular arrangement corresponds to six
Tinear arrangements, we have 6 X (Number of circular arrangements of A, B,... . F)
(Number of linear arrangements of A, B,.... F) = 61
‘Consequently, there ae 61/6 = 5! = 120arrangements of A,B, ..., Faround the circular
table
‘Suppose now that the six people of Example 1.16 are three married couples and that A, B,
‘and C are the females. We want to arrange the six people around the table so that the sexes
saltemate. (Once again, arrangements are considered identical if one can be obtained from
the other by rotation.)
Before we solve this problem, let us solve Example 1.16 by an alternative method,
\hich will assist us in solving our present problem. If we place A at the table as shown in
Fig. 1.3(@), five locations (clockwise from A) remain to be filled. Using B,C, ... , Fto fill12 Permutations "
A A
5 1 | ws Mi
sl 2) 8 Fe
3 Ma
@ ®
Figure 13
these five positions is the problem of permuting B, C,
ccan be done in 5! = 120 ways.
To solve the new problem of alternating the sexes, consider the method shown in
1.3¢b).A (a female) is placed as before. The next position, clockwise from A, is marked
MI (Male 1) and can be filled in three ways. Continuing clockwise from A, position F2
(Female 2) can be filed in two ways, Proceeding in this manner, by the rule of product,
there are 3X 2X 2X 1X 1 = 12 ways in which these six people ean be arranged with no
Fin a linear manner, and this
‘avo men or women seated next (0 each oxher.
Eran
4. During local campaign, cight Republican and five Demo-
cratic candidates are nominated for president of the schoo!
board,
4) IF the president isto be one of these candidates, how
‘many possibilities are therefor the eventual winner?
'b) How many possiblities exist for a pair of candidates
(one from exch party) to oppose each other for the eventual
election?
©) Which counting. principle is used in pare (a)? in
parc (6)?
2. Answer part (¢) of Example 1.6,
4. Buick automobiles come in four models, 12 colors, three
engine sizes, and ro transmission types. (a) How many distinct
Buicks can be manufactured? (b) Ione of the available colors
is blue, how many different blue Buicks can be manufactured?
4. The board of directors of a pharmaceutical comporation has
10 members. An upcoming stockholders’ meeting is scheduled
toapprove anew slate of company officers (chosen from the 1D
board members).
8) How many different slates consisting of apresident, vice
president, secretary, and treasurer ean the boaed present 9
the stockholders for their approval?
) Three members of the bostd of directors are physicians.
How many slates from par (a) have i) a physician nomi-
hated forthe presidency’ (@) exactly one physician appear
ing on the slate? (i) atleast one physician appearing on
the slate?
5, While on @ Saturday shopping spree Jennifer and Tiffany
witnessed two men driving away from the front ofa jewelry
shop, just before a burglar alarm started to sound. Although ev
cexything happened rather quickly, when the two young ladies
‘ere questioned they were able to give the police the following
information sbou the license plate (which consisted of two lee
ters followed by four digits) on the get-away car. Tiffany was
sure thatthe second letteron the plate was ether nO ora Q and
the lst digit was either a3 oran 8 Jenifer told the investigator
that the frst letter on the plate was either aC or a G and that the
first digit was definitely 27. How many different license plates
will the potice have to check out?
6. To raise money for a new municipal poo, the chamber of
‘commerce in acertaincity sponsorsa race. Bac paticipant pays
$5 onrance fee and has a chance to win one ofthe different
sized trophies that are 10 be awarded to the rst ight runners
who finish
8) If 30 people entre race, in how many’ ways will it be
possible to award the trophies?
1 IFRoberta and Candice are two participants in the ace,
Jn how many ways can the trophies be awarded with these
‘wo runners among the top three?
7 certain Burger Join” advertises that acustomer can have
his of her hamburger with or without any or all of the fol.
Towing: catsup, mostard, mayonnaise, lettuce, tomato, onion
pickle, cheese, or mushrooms. How many different kinds of
hamburger orders ae possible?R Chapter 1 Fundamental Principles of Counting
8, Matthew works as a computer operator ata small univer-
sity. One evening he finds that 12 computer programs have been
submitted earlier thet day for batch processing. In how many
‘ways can Matthew order the processing ofthese programs if
(a) there are no restrictions? (b) he considers four ofthe pro-
{ras higher inpririy than the other eight and wantsto process
‘those four fis? () he fist separates the programs into four of
top priority, five of lesser priority, and thee of least pricity,
and he wishes to process the [2 programs in such away that the
top-priority programs are processed is and the thee programs
lof least praity are processed last?
‘9. Patter’s Pastry Parlor offers cigh different kinds of pastry
and six different kinds of muffins. In addition to bakery items
‘one can purchase small, medium, or lage containers of the fol
lowing beverages: coffee (black, witheream, wth ugar, or with
cream and sugar, ta (plan, with cream, with sugar, with cream
‘and sugar, with lemon, of with lemon and sugar) hot cocoa, and
‘orange juice. When Carol comes to Patr's in how many ways
‘can she order
4) one bakery item and one medium-sized beverage for
horse?
1) one bakery item and one container of coffee for herself
‘and one muffin ané one container of tea for her boss, Ms.
Didio?
©) one piewe of pastry and one container of tea for herself,
‘one muffin snd a container of orange juice for Ms. Didio,
snd one bakery item and one container of coffee for each
of ber two assistants, Mr. Talbot and Mrs. Gillis?
10, Pamela has 15 differen books, In how many ways can she
place her books on wo shelves so tha there sa least one Book
‘on each shelf? (Consider the hooks in each arrangement to be
stacked one next tothe other, wih te fist Book on each shelf
atthe left of the shelf)
41, Thee small towns, designated by A, B, and C, are inter
connected by system of two-way roads, as shown in Fig. 1.4,
Figure 14
2) In bow many ways can Linda travel from town A to
town C?
'b) How many different round trips ean Linda travel from
town A to town Cand back to town A?
©) How many of the round tips in part (b) ate such that
the rerum trp (from town C to town A) i atleast partially
‘ifferent from the route Linda takes from town A to town,
(C? (For example, if Linda travels from town A to town C
slong roads Ry and Ra, then on ber return she might take
roads Ry and Rs, or roads Ry and Re, oF road Rs, among
‘ther possibilities, but she does not travel on roads Ry
and Ry.)
432, List all she permutations forthe leters a, et
13,
) low many permutations are there forthe eight letters
AGL BEL WX?
b) Consider the permutations in part (8). How many stat
with dhe letter? How many start with the letter ¢ and end
with the letter €?
44, Evaluate each ofthe following.
8) PO.2) b) P(B.4) ©) P(LO,7) ) PU2,3)
4S. In how many ways can the symbals a6 ¢, 6, €,€,6,€
be arranged so that noe is adjacent to another e?
416, Analphabet of 40 symbols is usedfortransmiting messages
ina communication system. How many dstinet messages (lists
‘ef symbols of 25 symbols can the transmitter generate if sym
bols can be repeated in the message? How mny if 10 of the
40 symbols can appear only asthe fest andlor last symbols of
the message, the other 30 symbols can appear anywhere, and
repetitions of all symbols are allowed?
47. Te the Intermet each network interface of & computer is a8=
signed one, or more, Internet addresses. The nature of these
Internet addresses is’ dependent on network size. For the It-
temmet Standard regarding reserved network numbers (STD 2),
‘each address is a 32-bit string which falls into one of the fol=
Towing three classes: (1) Aclass adress, used for the largest
networks, begins with a0 whichis then fllowed by aseven-bit
rnenvork number, and then a7-bit local address. However, one
is restricted from using the network numbers of all 0°s or all
1's and the local addrosses of all 0's or all I's (2) The class
B address is meant for an intermediatesized network. This ad-
dress stars withthe two-bit string 10, which is followed by a
14-bit network number and then a 16-bit local addres. But the
local addresses ofall 0's oral 1's ae not permitted, (3) Class ©
addresses are used for the smallest networks. Those adresses
consist ofthe three-bt string 110, followed by a 21-bit network
number, andthen aneight-bt local address. Once again the local
addresses ofall 0's o all I's are excluded. How many different
addresses of each class are available on the Internet, for this
Internet Standard?
18, Morgan is considering the purchase of low-end computer
system. After some careful investigating, she finds that there are
seven basic systems (each consisting of a monitor, CPU, Key~
‘bourd, and mouse) that meet her requirements. Furthermore, shealso plans to buy one of four modems, one of three CD ROM
drives, and one of six printers (Here ezch peripheral device of
a given type, such a the modem, is compatible with all seven
basic systems.) In how many ways can Morgan configure her
low-end computer system?
19, Avcomputr science professor has seven different program-
‘ming books on a bookshelf. Thee ofthe books deal with C++,
te other four with Java. In how many ways can the professor
arrange these books on the shelf (a) if there are no restrictions?
(6) ifthe languages should alternate? (c) if all the Cr Books
snus be next to each orher?(@) if al the C++ books must be
ext o.each other and al the Java hooks must be next to each
other?
20, Over the Internet, data are transmitted in structured blocks |
of bits called daragrams.
2) In how many ways can the letters in DATAGRAM be
arranged?
1b) For the arrangements of part (a). how many have all
three A’s together?
21, a) How many arrangements are there of all the eters in
‘SOCIOLOGICAL?
') In how many of the arangements in par (3) are A and
Gadjacent?
©) In how many ofthe arrangements in part (a) ar all the
‘vowels adjacent?
22, How many postive integers can we form using the digits
3,4, 4,5, 5,6, if we want n to exceed 5,000,000?
23, Thwelvecley targets (dential in shape) are arranged in four
hanging columns, as shown in Fig. 1.5. There ate four red tar
ses in the first cohuma, three white ones in the second column,
{wo green targets in the third column, and three blue ones in|
the fourth column. To join her college drill eam, Deborah must
break all 12 of these targets (using her pistol and only 12 bul
Jets) and in so doing must always break the existing target at
the bottom of a column. Under these conditions, in how many
itferent orders can Deborah shoot down (and break) the 12
targets?
LOO
©-©-©
©-O-©
12. Permutations 13
24, Show that forall integers mr = 0860-4 1 > rthen
net
aire)
25, Find the value(s) of min each of he following:
{4 Pon, 2) = 90, (6) PCs. 3) = 3PC,2), and
(01201, 2)+50= Pn 2)
rietn=(
26, How many different pats in the xy-plane are therefrom
(0,0) « (7, 7) if a path proceeds one step ata time by go
ing either one space t the right (R) or one space upward (U)?
How many such paths are there from 2, 7) 10 (9, 14)? Can any
‘general statement be mae tht incorporates these wo results?
m
) How many distinct paths are therefrom (1, 2, 0) to
(1,3, 7) in Euclidean tee-space if each move is one of
the following types?
sO, y. OF Lys
Wey, 2)- YL DY
AG y+ ytd
) How many such paths are there from (1.0, 5) 10
Qin?
©) Generalize the results in parts () and (b).
28, a) Determine the value of the integer variable counter af-
ter execution of the following program segment. (Here i,
Jang k are integer variables.)
counter += 0
for i :=1to12de
counter := counter +1
for j :=5to10do
counter := counter +2
for k i= 15 downto & do
counter := counter +3
1b} Which counting principle is at play in par (a)?
29, Consider the following program segment where f, J, and &
‘are integer variables,
for {:=1to12do
for j :=5 to 10 do
for k += 15 downto 6 do
print (1 -3)*k
8) How many times isthe prin statement executed”?
'b) Which courting principle i used in part (a)?
30, A sequence of letters ofthe form abba, were the expres-
sion is unchanged upon reversing order, is an example of =
‘palindrome (of five letters) (a) If letter may appear more than
twice, how many palindromes of ive leters are there? of six
Jewters? (b) Repeat part (a) under the condition that no letter
‘appears more than twice,4 Chapter 1 Fundamental Principles of Counting
Figure 18
31. Determine the number ofsix-igi integers (no leading ze-
0s) in which (a) no digit may be eepeateds (b) digits may be
repeated. Answer parts (a) and (b) with the extra condition that
the six-igi integer is (i) even; (i) divisible by 5; (i) divisible
by
32. 2) Provide # combinatorial argument to show tht ifm and
A are positive integers with a = 3k, then w!/(3)) is am ine
teger
1) Generalize the result of part (@),
38. a} In how many possible ways could a student answer a
10-question tru: false test?
1) In how many ways can the student answer the test in
part (a) if tis possible w leave a question unanswered in
‘order to avoid an extra penalty for @ wrong answer?
34, How many distinet four-digit integers can one make from
the digits 1, 3,3, 7,7, and 82
35. a) In how many ways can seven people be arranged about
circular table?
cry
) If two of the people insist om sitting next to eachother,
how snany arrangements are possible?
) In how many ways can cight people, denoted A,
B, ..., Hbe seated about the square table shown in Fig,
1.6, where Figs. |.6(2) and 1.60) are considered the same
but are distinct from Fig. 1.6(0)?
b) Iftwo ofthe eight people, say Aand B, do not get along
well, how many different seatings are possible with A and
B not siting next to each other?
teen people re tobe seated at two citcular tables, one
am
of which seats 10 while the other seats sx, How many diferent
seating artangements are possible?
38. A.commitiee of 15 —nine women and six men — is to be
Seated at acircular table (with 15 sets). In how many ways can
the seats be assigned so that no twvo men are seated next each
other?
39, Write a computer program (or develop an algorithm)
to determine whether there is a three-digit integer
‘abe (= 1a + 10b +c) where abe = al +b! +e!
Combinations: The Binomial Theorem
‘The standard deck of playing cards consists of 52 cards comprising four suits: clubs, di-
amonds, hearts, and spades, Bach suit has 13 cards: ace, 2, 3, ... , 9, 10, jack, queen,
king. If we are asked to draw three cards from a standard deck, in succession and without
replacement, then by the rule of product there are
a
52x 51x50 (52, 3)
a
possibilities, one of which is AH (ace of hearts), 9C (nine of clubs), KD (king of dia-
‘monds). If instead we simply select three cards at one time from the deck so that the order
Of selection of the cards is no longer important, then the six permutations AH-9C-KD,
AH-KD-9C, 9C-AH-KD, 9C-KD-AH, KD-9C-AH, and KD-AH-9C all correspond to
justone (unordered) selection. Consequently, each selection, or combination, of three cards,
with no reference to order, corresponds to 3! permutations of three cards. In equation formEXAMPLE 118
EXAMPLE 1.19
EXAMPLE 1.20
15 Combination: The Binal Theorem 6
this translates into
(31) (Number of selections of size 3 from a deck of 52)
‘Number of permutations of size 3 forthe 52 cards
sa
1
Consequently, throe cards can be drawn, without replacement, from a standard deck in
521/(3! 491) = 22, 100 ways,
= P(S2,3) =
It we star with n distinct objects, each selection, or combination, of r ofthese objects,
‘with no reference to order, corresponds tor! perintations of sizer from the n objects.
“Thus the number of combinations of size r from a collection of size is
P(n.r)
Can=
In addition to C(n,r) the symbol (7) is also frequently ased. Both C(n, r) and (9) are
sometimes read “n choose 7." Note that for all n > 0, C(n, 0) = C(n,n) = 1. Further, for
alln> LC(n, I) = Clnn— 1) =n. When 0 0, (2) = (,",). This can be established
algebraically from the formula for (*), but we prefer to observe that when dealing with
a selection of size r from a collection of m distinct objects, the selection process leaves
behind.» ~ objects. Consequently, (") ~ (,”,) affirms the existence of a comrespondence
between the selections of size (objects chosen) and the selections of size m ~ r (objects
left behind). An example of this correspondence is shown in Table 1.4, where n = 5,7 = 2,
and the distinct objects are 1, 2, 3, 4, and 5. This type of comespondence will be more
formally defined in Chapter 5 and used in other counting situations.
Selections of Siren — 7 = 3
(Objects Left Behind)
13,45 6 1,35
2 245 734
3. 2.35 B25
4234 O14
S45 10 1,23
ur second result is a theorem from our past experience in algebra,
THEOREM 1.1
The Binomial Theorem, If x and y are variables and m is a positive integer, then
sG)ere er EQ"
Before considering the general proof, we examine a special ease. If =
of x2y? in the expansion of the product
(HYG OH MEY
tt ane ars at
‘acer fader facer for2 Chapter Fundamental Pipes of Counting
is the number of ways in which we can select two xs from the four xs, one of which is
available in each factor. (Although the x's are the same in appearance, we distinguish them
asthe x in the frst factor, the x in the second factor, ... , and the x in the fourth factor.
Also, we note that when we select two 2s, we use two factors, leaving us with two other
factors from which we can select the two y's that are needed.) For example, among the
possibilities, we can select (1) x from the first two factors and y from the last two or (2) x
rom the first and third factors and y from the second and fourth, Table 1.5 summarizes the
six possible selections.
Table 15
Factors Selected for x
Consequently the coefficient of x2)? in the expansion of (x + 3) is (8) 6, the number
of ways to select two distinct objects from a collection of four distinct objects.
[Now we tur to the proof of the general case.
Proof In the expansion ofthe proxiuct
(tO FY Ot OEY
te anda nt
fader fedae fader ter
the coefficient of 4y"“*, where 0- 0,
9+ ()+G) +--+ () = 2% and
») (a) =H} +) —- +) = 0.
Proot: Past (a) follows from the binomial theorem when we set x = y = 1. When x
and y = 1, part (b) results,
‘Our third and final result generalizes the binomial theorem and is called the multinomial
theorem,
THEOREM 1.2 For positive integers n,¢, the coefficient of x'x!x3° x" in the expansion of
(abba tetaytis
miming
where each 1 is an integer with 0-< 7; 1, prove that (3) + ("3 ')
isa perfect square,
7. A.committee of 12 isto be selected from 10 men and 10
‘women, In how many ways can the scletion be cartied out if
(@) there are no restrictions? (b) there must be six mew and six
Women? (¢) there must be a even number of women? (there
‘must be more women than men? (e) there must best leas eight
8. In bow many ways can a gambler draw five cards from a
standard deck and get (a a flush (five cards ofthe same suit?
(b) four aces? (c) four ofa kind? () three aces aad two jacks?
(three aces and a pair? (1) a fll house (thee of kind and &
pie)? (g) three of a kind? (h) two pairs?
‘9. How many bytes contain (a) exactly two I's (b) exactly
four 1s: (&) exactly six I's, (@) atleast six 1'5?
10, How many ways are there wo pick a fve-person basketball
team from 12 possible players? How many selections include
the weakest snd the strongest players?
11, Astudent is toanswer seven out of 10 questions on anexam-
ination, In hows many wayscan he make his selection if (a) there
are no restrictions? (b) he must answer the fst two questions?
(©) he must answer at least four ofthe frst six questions?
12, In how many ways can 12 diferent books be distributed
among four children so that (a) each child gets three Books?
() the two oldest children get four books each and the two
youngest get two books each?
13, How many arrangements of the lewers in MISSISSIPPI
have no consecutive S's?
14, A gym conch must cet 1 seniors play on a foal
team if be can mae is selection in 1278 ways bow many
Sst ae clipe to pay?
16.) Fen points, othe of which recliner ae given
Gna plane. How many ince do tie deeming?
1) Twemy-five pois no fou of which are coplanar, ate
given in space How mary anges do they deermine?
How many planes? How many tetabedea(pyramidlike
Sod it rang faces)?
16, Deermine the value ch f the following summations
avery» LG=-v oSneem
8) S(-1 where a a postive inager
9 Dien
17, Express each of the following using the summation (or
Sigma) notation. In pans (a), (€), and (€),n denotes a positive
taal
a stat gttsDy 14449416 425436449
OV BsB a ES OEP
net
2
oo (&B)-E2)-€2)-
wn(@)
418, For the stings of length 10 in Example 1.24, how many
have (a) four 0's, three 1s, and three 2's: (b) at least eight I's:
(6) weight 4?
19, Consider the collection ofall strings of fength 10 made up
from the alphabet O, 1,2, and 3. How many of these strings
have weight 3? How many have weight 4? How many have
‘even weight?
20, Inthe three pars ofFig. 1.8, eight pons are equally spaced
tnd marked on the citoumference ofa given circle
©
Figure 18
4) For parts (a) and (b) of Fig, 8 we have two diferent
(@hough congruent triangles. These two triangles (istn-
guished by their vertices} result from two selections of size
3 from the vertices A. B,C, D, E, FG, H. How many dif-
ferent (whether congruent or no) triangles can we inscribe
inthe circle inthis way?
'b) How many diferent quadsilaterals can we inscribe inthe
circle, using the marked vertices? [One such quadrilateral
appears in part) of Fig. 1.8.1
(©) How many diferent polygons of three or more sides can
‘we inscribe in the given cireleby using three or more ofthe
marked vertices?
13 Combinations: The Binomial Theorem 25
21, How many wianles are determined by the vertices of &
regular polygon fm sides? How many i no side of the polygon
isto bea sie of ay wiangle?
22.) In the compete expansion of (a+ b-e-+a)
(e+ seed Mut usw trey +2 ow obuins he
sum of terms such as agu, cf, and dgv. How many soch
terms spper in this complete expansion?
Which ofthe following erms donor appear inthe com
plete expansion frm par (a)?
‘af i) bux ity che
Wy egw Yea wo adfz
23, Determine the coetcint of 2y* in the expansions of
(@ (e+ 9)". ) (+29), and (©) (Qe ~ 39)"
24, Complete the deals in the proof of the multinomial
there,
25, Determine the coefficient of
actin ty tot
by ayctinw bet y tot
6) xy2in ry 2)"
@ ayetin(e—2y 43H!
©) w'x*y2? in Qu ~ x +3y—22"
26, Find the cocficient of wy? in the expension of
Ge) (wt ety $241), 0) Qu—x+3y-+2—2), and
(ow 2b y HSC 43
27, Determine the sum ofall the cosfcients in the expan-
sions of
arty Oty"
Owtetyso®
©) Qs 3+ Su+6u~ Mw #3r +29)!
28. For any positive integer n determine
° Dan
Owtyen
fog
29. Show that forall postive imtegers m and n,
ar) C0)
With a postive integer, evaluate the sur
he) 20-20)
ay eaiear- (Sear
+ (fearon ren(")
aror-(Narnersi
jerite ser? ncr(Senr26 Chapter 1 Fundamental Prncpes of Counting
or-eur-(hess D) Given a lista a). a
+(Qeeser-
32, Determine x if D%, (V8 = x.
> af four rest nme, wats Rute sca ave Pome oce a
of n+l real
rnumbers, where nis a pesttive integer, de
(a4),
ser(e
34, a) Write @ computer program (or develop an algorithm)
5,6
'b) Repeat part () for selections of size 3,
ry
Combinations with Repetition
EXAMPLE 1.28
When repetitions are allowed, we have seen that for n distinct objects an arrangement of
size r of these objects can be obtained in n’ ways, for an integer r > 0. We now turn to
the comparable problem for combinations and once again obtain a related problem whase
solution follows from our previous enumeration principles
‘On their way home from track practice, seven high school freshmen stop at a restaurant,
where each of them has one of the following: a cheeseburger, ahot dog, a taco, ora fish sand-
wich. How many different purchases are possible (from the viewpoint of the restaurant)?
Let, ht, and f represent cheeseburger, hot dog, taco, and fish sandwich, respectively
Here we are concerned with how many of each item are purchased, not with the order
in which they are purchased, so the problem is one of selections, or combinations, with
repetition
In Table 1.6 we list some possible purchases in colurnn (a) and another means of repre-
senting each purchase in column (b)
‘ables
1 T xxixxtextx
2 Rxxxlalx}x |
3 cececef | 3 xxxxxxiflx |
4 RULEEEE 4 Ixaxiaxax |
5 Quneene 5. ||xxxxx|xx
6 GhoKuut 6 |[Xxxxxxx
TABLE RE T_[IRAXR RX
@ ®
For a purchase in column (b) of Table 1,6 we realize that exch x to the left ofthe first bar
(represents c, each x between the first and second bars represents an h the x's between
the second and third bars stand for t's, and each x to the right of the third bar stands for
‘an f. The third purchase, for example, has three consecutive bars because no one bought
‘2 hot dog or taco; the bar at the start of the fourth purchase indicates that there were no
cheeseburgers in that purchase,
(Once again a correspondence has been established between two collections of objects.
where we know how to count the number in one collection, For the representations inEXAMPLE 1.29
__ EXAMPLE 130
14 Combinations wih Repetition a
column (b) of Table 1.6, we are enumerating all arrangements of 10 symbols consisting
of seven x’s and three |s, so by our correspondence the number of different purchases for
column (a) is
wot _ (10
ma ( 7 )
In this example we note that the seven x's (one for each freshman) correspond fo the size
of the selection and that the three bars are needed to separate the 3 + 1 = 4 possible food
items that can be chosen,
‘When we wish o select, wi repetition, rofm distinct objects, we find (as in Table 1.6)
that we are considering all arrangements ofr x'sandn ~ 1's and that their namber is
(tr— Dt (4)
‘Consequently, tie number of combinations of m objects taken r ata time, with repetition,
isCintr—1,r).
(in Example 1.28, »
allowed)
= 4,1 =7, so it is possible for r to exceed n when repetitions are
A donut shop offers 20 kinds of donuts. Assuming that there are at least adozen of each kind
when we enter the shop, we can selectadozen donuts in C(20 + 12 ~ 1, 12) = C(31,
141,120,525 ways. (Here n = 20,7 = 12.)
President Helen has four vice presidents: (1) Betty, (2) Goldie, (3) Mary Lou, and (4) Mona.
She wishes to distribute among them $1000 in Christmas bonus checks, where each check
‘will be written for a multiple of $100,
a) Allowing the siwation in which one or more of the vice presidents get nothing,
President Helen is making. a selection of size 10 (one for each unit of $100) from
a collection of size 4 (four vice presidents), with repetition. This can be done in
C+ 10 1, 10) = CH, 10) = 286 ways.
by) If there ae to be no hard feelings, each vice president should receive atleast $100. With
this restriction, President Helen is now faced with making a selection of size 6 (the
remaining six units of $100) from the same collection of size 4, and the choices now
number C4 +6 ~ 1, 6) = C(9, 6) = 84. [For example, here the selection 2, 3, 3,4,
4, 4 is imerpreted as follows: Betty does not get anything extra—for there is no | in
the selection. The one 2 in the selection indicates that Goldie gets an additional $100,
‘Mary Lou receives an additional $200 ($100 for each of the two 3's inthe selection),
Due to the three 4's, Mona's bonus check will total $100 + 3($100) = $400.)28 (Chapter 1 Fundamental Prncpes of Counting
©) If each vice president must get at least $100 and Mona, as executive vice president,
gets at least $500, then the number of ways President Helen can distribute the bonus
checks is
CG42~1,946B4+1~1,+CB40- 1,0) =10=C4+2-1,2)
Mon es Moa gets ora pts ing te
eat 50 eadiy 00 way 00 tein prt)
Having worked examples utilizing combinations with repetition, we now consider two
examples involving other counting principles as wel
Jn how many ways can we distribute seven bananas and six oranges among four children
so that each child receives at least one banana?
After giving each child one banana, consider the number of ways the remaining three
‘bananas can be distributed among these four children. Table 1.7 shows four of the distri-
butions we are considering here. For example, the second distribution in part (a) of Ta
ble L7—narely, 1, 3, 3—indicates that we have given the first child (designated by 1)
‘one additional banana and the third child (designated by 3) two additional bananas. The
corresponding arrangement in part (b) of Table 1.7 represents this distribution in terms of
three b's und three bars. These six symbols — three of one type (the b's) and three others ofa
second type (the bars) —can be arranged in 61/(3! 31) = C(6, 3) = C4 +3— 1, 3) = 20
ways. [Here n= 4, r = 3.] Consequently, there are 20 ways in which we can distribute
the three additional bananas among these four children, Table 1.8 provides the compa-
rable situation for distributing the six oranges. In this case we are arranging nine sym-
bols—six of one type (the o's) and three of a second type (the bars). So now we learn
that the number of ways we can distribute the six oranges among these four children is
91/6613) = CO, 6) = C4+6 ~ 1, 6) = 84 ways, [Here n = 4,r = 6] Therefore, by the
rule of product, there are 20° 84 = 1680 ways to distribute the fruit under the stated
conditions.
Table 7 Table 18
na 1D bibIb) 1) 12,2334 | 1 eloolooio)
Da 2) di tbel 2 1.22444 | 2 cloelloooe
33 3) [1b 1b 3 2.22333 | 9 looolooo|
4) 444 | 4) [ipod 4) 44.4444 | 4) Iloo0000
@ ® @ 0
‘A message is made up of 12 different symbols and is to be transmitted through a com-
‘munication channel. In addition to the 12 symbols, the transmitter will also send 2 total
‘of 45 (blank) spaces between the symbols, with at least three spaces between each pair of
‘consecutive symbols. In how many ways can the transmitter send such a message?
‘There are 12! ways toarrange the 12 different symbols, and for each of these arrangements
there are 11 positions between the 12 symbols. Because there must be atleast three spaces
between successive symbols, we use up 33 of the 45 spaces and must now locate the
remaining 12 spaces. This is now a selection, with repetition, of size 12 (the spaces) from a
collection of size 11 (the locations), and this can be accomplished in C(I + 12 ~ 1, 12) =
616,646 ways.
[EXAMPLE 1.32EXAMPLE 1.33
EXAMPLE 134 |
1.4. Combinations with Repetition 29
Consequently,
required spacing in (12 (3)
y the rule of product the transmitter can send such messages with the
3.097 X 10" ways
In the next example an idea is introduced that appears to have more to do with number
theory than with combinations or arrangements. Nonetheless, the solution of this example
will tum out to be equivalent to counting combinations with repetitions.
Determine all integer solutions to the equation
mtmtuyt=7, wheres, 20 forall sis,
‘One solution of the equation is xy = 3,2 = 3,15 = O,.x4 = 1. (This is different froma
solution suchas.ry = 1x2 = 0,15 = 3,x4 = 3,even though the same four integersare being
used.) A possible interpretation forthe solution x = 3, x5 = 0,44 = Listhatweare
distributing seven pennies (identical objects) among four children (distinet containers), and
here we have given three pennies fo each of the first wo children, nothing to the third child,
and the last penny to the fourth child. Continuing with this interpretation, we see that each
nonnegative integer solution of the equation corresponds to a selection, with repetition, of
size 7 (the identical pennies) from a collection of size 4 (the distinct children), so there are
C4+7~1, 7) = 120 solutions
At this point it is crucial that we recognize the equivalence of the following
‘8) The number of integer solutions of the equation
Ktmtetmen 20 Lshem,
) The number of selections, with repetition, of size r from a collection of size n,
©) The number of ways r identical objects can be distributed among 7 disinet
containers.
In terms of distributions, part (c) is valid only when the r objects being distributed are
identical and the » containers are distinet, When both the r objects and the 1 containers
are distinct, we can select any of the 7 containers for each one of the objects and get n"
distributions by the rule of product
‘When the objects are distinct but the containers are identical, we shall solve the problem
using the Stirling numbers ofthe second kind (Chapter 5). For the final case, in which both
‘objects and containers are identical, the theory of partitions of integers (Chapter 9) will
provide some necessary results
In how many ways can one distribute 10 (identical) white marbles among six distinct
‘containers?
Solving this problem is equivalent w finding the number of nonnegative integer solutions
tothe equation x +.1) +--+ .x¢ = 10. That numbers the number of selections of size 10,
with repetition, from a collection of size 6, Hence the answer is C(6-+ 10— 1, 10) = 3003,
\We now examine two other examples related to the theme ofthis section30 Chapter 1 Fundamental Principles of Counting
EXAMPLE 1.35
(eamete 7]
From Example 1.34 we know that there are 3003 nonnegative integer solutions to the
equation x; +2-+--- + x6= 10. How many such solutions are there to the inequality
nya tebe < 10?
One approach that may seem feasible in dealing with this inequality is to determine
the number of such solutions to xy ++.x9 +--+ 5 = k, where k is an integer and 0 <
k 9. Although feasible now, the technique becomes unrealistic if 10 is replaced by a
somewhat larger number, say 100. In Example 3.12 of Chapter 3, however, we shall estab-
lish a combinatorial identity that will help us obtain an alternative solution to the problem
by using this approach.
FFor the present we transform the problem by noting the correspondence between the
nonnegative integer solutions of
By tay bee hay <10 ao
and the integer solutions of
ntmtetaety el, Ose, si Oem @
The number of solutions of Eq, (2) is the same as the number of nonnegative integer
solutions of y+ y2-+:---hyp-+yy =9, where 91 =x, for 1 0.
‘This is equal to the number of integer solutions for
ayta= 5, where xx 20,
‘The number of such solutions is +4!) = (8)
il) Continuing with our nextcase, we examine the compositions with thre (positive)
summands, So now we want 1 count the number of postive integer solutions for
vito ya
‘This is equal to the number of nonnegative integer solutions for
atntas4
‘and that numberis (**$-"} = (3)
‘We summarize cases (), (i) and Gi), and the other four cases in Table 1.9, where we
recall for case (i) that 1 = (8)
Gi) wo
(iii) ay)
co) w
” o &
(wi) wi) ri
oi) wid32
EEE
EXAMPLE 1.38
Chapter 1 Fundamental Principles of Counting
Consequently, the results from the right-hand side of our table tell us that the (total)
number of compositions of 7 is
O+0)+0)+0)+O +020)
In general, one finds that for each postive integer m, there are Saf ("7
compositions
From Example 1.37 we know that there are 2°°-! = 2" = 2048 compositions of 12. If
‘our interest isin those compositions where each summand is even, then we consider for
instance, compositions such as
24+446= 214243) 248+
B+242= 244141 6+!
2440)
2043)
In each of these four examples, the parenthesized expression is a composition of 6. This
‘observation indicates that the number of compositions of 12, where each summand is even,
‘equals the number of (all) compositions of 6, which is 2°-! = 25 = 32,
‘Our next swe examples provide applications from the area of computer science, Further
more, the second example will lead to an important summation formula that we shall use
in many later chapters,
EXAMPLE 139°] CoMsider the following program segment, where i,j, and k are integer variables
for i
1 to 20 do
for j :=1teido
fork :e1tojdo
print (i+ +k)
How many times is the print statement executed in this program segment?
‘Among the possible choices for i, j, and & (in the order i-first, second, k-third) that
will lead to execution of the print statement, we list (1) 1, 1, 1: (2) 2, 1, 1:(3) 15, 10, 1s
and (4) 15, 10, 7. We note that = 10, j = 12, k = 5 is not one of the selections to be
considered, because j = 12> 10; this violates the condition set forth in the second
for loop. Each of the above four selections where the print statement is executed satisfies
the condition 1 1to ido
counter := counter + 1
Fromthe resultsin Example 1.39, after this segment isexeouted the value of the variable)
counter willbe (°73~!) = (°5") (This is also the number of times thatthe statement
o counter i+ counter +1
is executed.)
‘This result can also be obtained as follows: When i:= 1, then j varies from 1 to 1 and
(is executed once: when i is assigned the value 2, then j varies from 1 to 2 and (*) is
executed twice; j varies from 1 103 when iis assigned the value 3, and (*) is executed three
times; in general, for 1 =A <<, when = &, then j varies from 1 10 & and (*) is executed
- times. In total, the variable counter is incremented [and the statement (*) is executed]
142434----ba times,
Consequently,
Srewtaoeae tee (2) ntl)
‘The derivation of this summation formula, obtained by counting the same result in two
different ways, constitutes a combinatorial proof.
Our last example for this section introduces the idea of a run, a notion that arises in
statistics — in particular, in the detecting of trends in a statistical process.
‘The counter at Patti and Terri's Bar has 15 bar stools. Upon entering the bar Darrel finds
the stools occupied as follows:
OOEOOOOE
oo00£O
wee 0 indats anon so] nd Ean empty oe He We art conse With
theacuputaf he sols tote ora to! eoeuied) nia we) a
the enspaey ate IS set deems seven vn show
20 £ 2000 EEE 000 Bo
Seater eee
Ingenta nis aconeutve st ena nes it are preceded and allowed by
secon may nich Ne an 100° can be ange o provide sven si
EOOOEEOOEOOOOOE
‘We want to find the total number of ways five E's and 10 O's can determine seven runs.
If the first eum starts with an B, then there must be four runs of Bs and three runs of O's,
Consequently, the last run must end with an E.
Let x) count the number of Es in the first run, x2 the number of O's in the second run,
x the mumber of B's inthe third run, ..., and x; the number of E’s in the seventh run. We
‘want to find the number of integer solutions for
ntti ta Hy 24, 5,487 > 0 ®4
(Chapter Fundamental Principles of Counting
and
mtxetxe= 10, x, 4, 16> 0. @
‘The number of integer solutions for Eq. (3) equals the number of integer solutions for
mtytosty
‘This number is (**4~") = (3) =4. Similarly, for Eq. (4), the number of solutions is
43>") = @) = 36. Consequently, by the nile of product there are 4 - 36 = 14 arrange-
ments of five Es and 10 0°s that determine seven runs, the first rn starting with E
‘The seven rans may also have the first run starting with an O and the last run ending
with an O. So now let a; count the number of O's in the first run, w the number of B's in
the second run, w3 the numberof O's inthe thd run, .... and w7 the number of O's in the
seventh sun, Here we want the number of integer solutions for
Yi dIZO.
wy by fans + wy 10, wy, wy, as, lp > O
and
wa bus +6 >0.
Arguing as above, we find that the number of ways to arrange five E's and 10 O's, resulting
in seven runs where the first run starts with an 0, is @*E—")("F2!) = (JQ
‘Consequently, by the rule of sum, the five E'sand 100% canbe arranged in 148 -+ 504
‘648 way’ to produce seven runs
EXERCISES 1.4
1. In how many ways ean 10 (identical) dimes be distributed
among five children if (a) there are no restrictions? (b) each
child gets at least one dime? (c) the oldest child gts at east two
dimes?
2, In how many ways can 15 (identical candy bars be dis-
tributed among five children so thatthe youngest ges only one
cor two of them?
3. Determine how many ways 20 coins can be selected from
four large containers filled with pennies, nickels, dimes, and
quarters, (Each container is lle with only ane type of coin.)
4. Acertain ice cream store as 31 lavors of ice cream a
sl. In how many ways can we order a dozen icecream cones
i (@) we do not want the same flavor more than once? (b) a
flavor may be ordered as many as 12 times? (c) a avor may be
ordered no more than LI rimes?
5, a) Inhow many ways can we select five coins ftom a col.
Jection of 10 consisting of one penny, one nickel, one dime,
‘one quarter, one half-dllar, and five (identical) Susan B,
‘Anthony dollars?
bb) In how many ways can we select m objets from a eol-
lection of size 2n that consists of distinct and identical
objects?
6, Answer Example 1.32, where the 12 symbols being trans-
mitted are four A’s, four B's, and four C's.
7. Determine the numberof integer solutions of
si batas bas 32,
bx >0,
@ 28 (sist @x2-2 1sisd
Nam, 06525
8. In how many ways cana teacher distribute eight chocolate
donuts and seven jelly donuts among three student helpers if
‘ach helper wants at last one dont of each kind?
9, Columba has two dozen each of» different colored beads
If she can select 20 beads (with repetitions of colors allowed)
in 230,230 ways, what is the value of n?
10, In how many ways can Lisa toss 100 (identical) dice so that
at least three ofeach typeof face will be showing?
11, Two n-ipitintegers (leading zeros allowed) are considered
equivalent if one isa rearrangement ofthe other (For example,
3, 20331, and 01332 are considered equivalent five-digit
integers.) (a) How many five-digit integers are not equivalent?
(if the digits 1, 3, and 7 can appear at most once, how many
nonequivalent five-digit integers are there?12, Determine the number of integer solutions for
Ny baa tata tay 0?
19. How many times isthe print statement executed for the
following program segment? (Here, j,k, ond m are integer
variables.)
for iii te20d0
for j r= 1to ido
fork :=1 to j do
for m:=1tokdo
print (i* j) + (k* a)
20. In the following program segment, i,j, 4, and counter ace
integer variables. Determine the value tha the variable counter
will have after the segment is executed.
counter := 10
for {i= 1 t0 15 do
for j :-ite1sdo
fork := j to15 de
counter := counter +1
21. Find the value of sum after the given program segment is
executed. (Here i,j, iuerement, and stm ate iteger vari-
ables.)
114. Combinations with Repetition 35
increment := 0
sun := 9
for i:=1te10do
for j:=1toido
fork: 1toj do
begin
Sncrement := increment +1
end
22. Consider the following program segment, where fj 7
land counter are integer variables and the value ofn (a postive
integer) is st prior to this segment
counter := 0
fori :=1tonde
forj i=itoide
fork :=1toj do
counter := counter «2
‘We shall determine, in to different w
the statement
the numberof times
counter := counter + 2
is executed. (This is also the vale of counter after execution
‘ofthe program segment) From the result in Example 1.39, we
Know thatthe statement is executed (°°2°!) = ("42) times,
For a fixed value off, the for loops involving j and & result
in (/5") executions ofthe counter increment statement. Conse-
‘quently, (*$2) = 7, (752). Use this esult to obtain a sum-
‘nation Formula for
BaD bat
23. a) Given positive integers mm with mn. show thatthe
‘number of ways to distribute m identical objets into m dis-
tinet containers with no contain left empty is
Com = 1,m-=n) = Clim ~1,n= 0).
'b) Show that the numberof distributions in par (a) where
each container holds at least r objects (m = nr) is
Com —140 =n =D.
24, Wete computer program (or develop an algorithm) to list,
the integer solutions for
a) xy tabs = 10,
D) a tah hay
25. Consider the 2" compositions of 20. (a) How many have
each summand even? (b) How many have each summand a
multiple of 4?
26, Let n,m, K be positive integers with n = mk. How many
compesitions of m have each summand a multiple of k?
27, Frannie tosses acoin 12times and gets five heads and seven
tails, In how many ways can these tosses result in (a) two runs
of heads and one run of tails; (b) three runs: (c) four runs:
On,
1sis3
Isis36 Chapter Fundamental Principles of Counting
(4 ve rns (es rams and (equal mumbers of runs of) For n> 6, how many stings of» 0's and 1's contin
peal andra oft? (exe) dee excenes of 017
2B, a) Foen 2 4 comsderhe sings mae upofmbis—that__e) Prove a combinatorial proof othe flowing
avn ote Ova Tu le puncur comer hoe Fav
Stings where tee ate (exact) wo oecrenes of 01 tae ea
Forevanpe noe wt mctie stings chen >= ("EY 4(' See fe
010010 and 100101, but not 101111 ar 010101. How many V1 ($1). meven,
such stings are there?
15
The Catalan Numbers (Optional)
Inthis section a very prominent sequence of numbers is introduced. This sequence arises in
a wide variety of combinatorial situations. We'll begin by examining one specific instance
Where it is found.
EXAMPLE 142) L*t Start atthe point (0, 0) in the xy-plane and consider two kinds of moves:
Royo thy) UG. y)- Oy td,
‘We want to know how we ean move from (0, 0) 10 (5
the right orone unit up, So we'l need five R's and five U's. Atthis point we havea situation
like that in Example 1.14, so we know there are 101/(5! 5) = ('2) such paths. But now
‘we'll add a twist Tn going from (0, 0) (, 5) one may touch but never rise above the line
y= x, Consequently, we want to include paths such as those shown in pats (a) and (b) of
Fig. 1.9 but not the path shown in part ().
“The frst thing that is evident is that each such arrangement of five R's an five U's must
start with an R (and end with a U). Then as we move across this type of arrangement —
‘going from left to right —the number of R's st any point must equal or exceed the number
Of U's, Note how this huppens in pars (a) and (b) of Fig. 1.9 but not in part (c). Now we
can solve the problem at hand if we can count the paths [lke the one in part (C)] that go
from (0,0) 10 (S, 5) but rise above the line y = x. Look again atthe path in part (©) of
Fig. .9, Where does the situation there break down for the frst time? Afterall, we start
with the requisite R—then follow it by a U. So far, so good! But then there isa second U
and, at this (fst) time, the number of U's exceeds te numberof R's
‘Now let us conser the following transformation:
) using sueh moves —one unit 10
RU,U,
URRRUUR © RUU, | RUUUR RU.
‘What have we done here? For the path on the left-hand side of the transformation, we
located the first mave (the second U) where the path rose above the line y = x, The moves
up to and including this move (the second U) remain as is, but the moves that follow are
interchanged —each U is replaced by an R and each R by a U, The result is the path on
the right-hand side of the transformation — an arrangement of four R’s and six U's, as seen
in par (d) of Fig. 1.9, Part (e) of that figure provides another path to be avoided; part (f)
shows what happens when this path is transformed by the method described above. Now
suppose we start with an arrangement of six U's and four R's, say
R,URRUUU, | UU.