Você está na página 1de 6

SFWR ENG 2E03 Problem Set III Solutions

Marc Bender, Nov. 1 2005


1. Let A be a set of n elements.
(a) How many binary operations are there on A?
Solution: Recall from Problem Set I, question 7, that there are
|C|
|B|
functions B C, for any sets B and C. Binary operations are
functions (AA) A; therefore, there are a total of n
(nn)
= n
n
2
binary operations on A.
(b) How many of these are commutative (i.e. satisfy f(x, y) = f(y, x)
for all x, y in A)?
Solution: (1-pjr) To choose a commutative binary operation f on A
requires us to assign to each ordered pair (x, y) an element f(x, y).
There are two kinds of pairs, those for which x = y (there are n of
these), and those for which x = y. For the latter, we must assign
a value for each two-element subset {x, y} of A, since f(x, y) and
f(y, x) must be the same. There are, of course,
_
n
2
_
two-element
subsets. Thus choosing f is like choosing a function from a set of
cardinality
_
n
2
_
+ n =
n(n 1)
2
+ n =
n(n + 1)
2
to A. The number of such functions is n
n(n+1)
2
.
Solution: (2-mb) Since f(x, y) = f(y, x), the order of fs arguments
doesnt matter. So we can see f as a mapping from sets {x, y}
A to elements in A. The number of possible sets {x, y} is like
_
n
2
_
,
but with repetitions (for the case when x = y). The formula for
combinations with repetitions is on p. 340 of the text (
(n+r1)!
r!(n1)!
);
there are
(n + 2 1)!
2!(n 1)!
=
n(n + 1)
2
such combinations of A, so in total there are
n
n(n+1)
2
commutative mappings from (AA) to A.
1
2. Suppose f is a binary operation on a set A. An element e A that
satises f(x, e) = f(e, x) = x for all x A, is said to be an identity
element for f.
(a) Prove that a binary operation has at most one identity element.
Solution: Say we have identity elements d and e. These satisfy
f(x, d) = f(d, x) = x for all x (1)
f(x, e) = f(e, x) = x for all x (2)
Substituting yields
f(e, d) = f(d, e) = e by (1) (substituting e for x)
f(d, e) = f(e, d) = d by (2) (substituting d for x)
So d = e. Thus there can be at most one identity element.
(b) For a set A of n elements, how many binary operations have an
identity element?
Solution: There are n choices for the identity element, which has
only one possible behaviour. The remaining n 1 elements can be
mapped arbitrarily, so there are
n n
(n1)
2
= n
(n1)
2
+1
= n
n
2
2n+2
binary operations with an identity element.
3. A set P of nonempty subsets of a set A is called a partition of A if
(a) Its members are pairwise disjoint (i.e. (P
1
P) (P
2
P) =
((P
1
P
2
) = (P
1
= P
2
))), and
(b) Its union is A (i.e. x A = (P P) with x P).
If |A| = 6, how many partitions does A have?
Solution: (1-pjr-ad hoc) We classify the partitions according to how
many subsets are involved in the partition.
(a) 6 subsets of cardinalities (1, 1, 1, 1, 1, 1). There is only 1 such parti-
tion.
2
(b) 5 subsets of cardinalities (2, 1, 1, 1, 1). There are 15 such partitions.
(c) 4 subsets of cardinalities (3, 1, 1, 1). There are
_
6
3
_
= 20 such parti-
tions.
4 subsets of cardinalities (2, 2, 1, 1). There are 3
_
6
2
_
= 45 such par-
tition. This is because once you choose the 2 elements that will
be singletons (one-element subsets) there are 3 ways to pair up the
remaining four elements. A common error would be to compute
_
6
4
__
4
2
_
= 90. This would be correct if you cared about the order in
which the 2-element subsets were listed, but you dont.
(d) 3 subsets of cardinalities (4, 1, 1). There are
_
6
2
_
= 15 partitions of
this type.
3 subsets of cardinalities (3, 2, 1). There are
_
6
3
__
3
2
_
= 60 partitions
of this type.
3 subsets of cardinalities (2, 2, 2). The number of ordered triples of
2-element subsets is
_
6
2
__
4
2
_
= 90. However, this counts each triple
3! = 6 times. Dividing 90 by 6 gives 15 which is the correct number
of partitions of this type.
(e) 2 subsets: These can be of cardinalities (5, 1), (4, 2), and (3, 3).
The respective number of partitions is 6, 15, and 10. Again, you
might be tempted to say 20 for the (3, 3) case, but that would be
correct only if you wanted to distinguish between a rst triple
and a second triple of elements.
(f) 1 subset of cardinality 6. Of course, there is only one such partition.
The total number of partitions is therefore 1+15+65+90+31+1 = 203.
This is the ad-hoc solution. Marcs solution (2) is more sophisticated
and works for any nite set, not just one of cardinality 6. You can learn
something from both solutions.
Solution: (2-mb-general) Write
_
n
m
_
for the number of ways to partition
a set of size n into m subsets. First, notice that
_
i
1
_
=
_
i
i
_
= 1 for any
i 1 because any set B can be partitioned into singletons in exactly
one way, {{x} | x B}, and into sets of cardinality |B| in exactly one
way, {B}. The following identity holds for n k 1 (compare Pascals
Identity, p. 330 of the text):
_
n + 1
k
_
=
_
n
k 1
_
+ k
_
n
k
_
(3)
3
To see why, consider any set B of size n + 1. Take some b B, and
let B

= B {b}. There are


_
n
k
_
ways to partition B

into k subsets;
we can add b to any one of those subsets to arrive at a partition of B.
This gives us k
_
n
k
_
ways to partition B into k subsets. Additionally,
there are
_
n
k1
_
ways to partition B

into k 1 subsets, to which we can


add the singleton {b} as a subset, which gives a partition of B into k
subsets. So in total there are
_
n
k1
_
+ k
_
n
k
_
ways to partition B into k
subsets.
We can calculate the values we need to solve the question by building a
pyramid like Pascals triangle using (3):
_
1
1
_
_
2
1
_ _
2
2
_
_
3
1
_ _
3
2
_ _
3
3
_
_
4
1
_ _
4
2
_ _
4
3
_ _
4
4
_
_
5
1
_ _
5
2
_ _
5
3
_ _
5
4
_ _
5
5
_
_
6
1
_ _
6
2
_ _
6
3
_ _
6
4
_ _
6
5
_ _
6
6
_
=
1
1 1
1 3 1
1 7 6 1
1 15 25 10 1
1 31 90 65 15 1
We want all of the ways of partitioning A, so we sum up the boxed
values:
6

i=1
_
6
i
_
= 1 + 31 + 90 + 65 + 15 + 1 = 203
The numbers given by
_
n
m
_
are called Stirling numbers of the second
kind, and can also be calculated by evaluating
_
n
k
_
=
1
k!
k1

i=0
(1)
i
_
k
i
_
(k i)
n
.
4. Do Question 46, p. 312 of the text. Treat upper case and lower case
letters as distinct (e.g. x and X).
The name of a variable in the C programming language is a string that
can contain uppercase letters, lowercase letters, digits, or underscores.
Further, the rst character in the string must be a letter, either up-
percase or lowercase, or an underscore. If the name of a variable is
determined by its rst eight characters, how many dierent variables
can be named in C? (Note that the name of a variable may contain
fewer than eight characters.)
4
Solution: There are 26 each of uppercase and lowercase letters, 10 digits,
and 1 underscore. So there are a total of 26+26+1 = 53 choices for the
rst character, and 26+26+1+10 = 63 choices for the other characters.
The variable name can be 1 to 8 characters long, and there are 53(63
i1
)
names of length i, so the the total number of variable names is
7

i=0
53(63
i
) =
53(63
8
1)
62
5. Do Question 18, p. 325 of the text (about coin ipping):
A coin is ipped eight times where each ip comes up either heads or
tails. How many possible outcomes
(a) are there in total?
Solution: 2
8
= 256.
(b) contain exactly three heads?
Solution:
_
8
3
_
= 56.
(c) contain at least three heads?
Solution: 2
8

_
8
2
_

_
8
1
_

_
8
0
_
= 219.
(d) contain the same number of heads and tails?
Solution:
_
8
4
_
= 70.
6. Do Question 19, p. 342 of the text (about identical twins). The answer
is given in the book. You have to work out the details.
Suppose that a large family has 14 children, including two sets of iden-
tical triplets, three sets of identical twins, and two individual children.
How many ways are there to seat these children in a row of chairs if the
identical triplets or twins cannot be distinguished from one another?
Solution: This is a simple example of permutations with indistinguish-
able objects (see Example 8, p. 339 of the text). The answer is
14!
3! 3! 2! 2! 2!
= 302, 702, 400
Note from pjr: Recalling examples we did in class, this is the same
problem as the following: A father brings home a box of 14 Tim Hortons
5
donuts: 3 old fashioned plain, 3 Boston Cream, 2 maple dip, 2 chocolate
glaze, 2 vanilla dip, 1 jelly-lled, 1 walnut crunch. In how many ways
can he feed them to his 14 children (one donut per child, of course)? It
is also the same as the problem of how many distinct strings can you
form from the letters AAABBBCCDDEEFG.
This is, of course, dierent from the problem of how many fathers could
each buy a box of 14 donuts for their respective families with no two
getting the same combination, assuming there are 25 avours available.
Solution (2) to Question (1b) also deals with the same problem. How
many distinct orders of 2 donuts can you have if there are n avours
available? In this case, a set {x, y} corresponds to a pair of donuts of
avours x and y, where x and y are allowed to be the same.
7. Do Question 18, p. 351 of the text (about points in a square).
Show that if ve points are picked in the interior of a square with a side
length of 2, then at least two of these points are no farther than

2
apart.
Solution: Divide the square into four squares as follows:
2
2

1
1 1
1
The diagonal of a 1 1 square measures

2, so if we want our points
to be at least

2 apart, there can be at most one point in each of
the smaller squares (just use Pythagoras theorem). So we can t four
points, with minimum separation of

2, into the large square, but by
the pigeonhole principle, the fth point must be in the same square as
one of the other points. Thus, at least two of the points are no farther
than

2 apart.
6

Você também pode gostar