couting slides
couting slides
Lecture # 21
1
COUNTING
In combinatorics we generally solved counting problems.
4
BASIC COUNTING PRINCIPLES
The two basic counting principles are:
Product Rule
Sum Rule
5
EXAMPLE
Your institute is offering 7 courses in computer science
and 3 courses in mathematics.You are asked to choose
only one course.
How many choices you have?
n 1 + n 2.
7
EXAMPLE
A student can choose a computer project from one of
the three lists. The three lists contain 23, 15 and 19
possible projects, respectively.
9
SUM RULE IN TERMS OF SETS
If A1, A2, …, Am are finite disjoint sets, then the number of
elements in the union of these sets is the sum of the
number of elements in them.
10
EXAMPLE
Suppose
There are 7 different optional courses in Computer
Science and
3 different optional courses in Mathematics.
7 3 = 21 choices.
11
THE PRODUCT RULE
If one event can occur in n1 ways and if for each of these
n1 ways, a second event can occur in n2 ways.
12
EXAMPLE
The chairs of an auditorium are to be labeled with two
characters, a letter followed by a digit.
13
SOLUTION
The procedure of labeling a chair consists of two events,
namely,
14
GENERALIZED PRODUCT RULE
If some event can occur in n1 different ways, and if,
following this event, a second event can occur in n2
different ways, and following this second event, a third
event can occur in n3 different ways, …, then the number
of ways all the events can occur in the order indicated is
15
PRODUCT RULE IN TERMS OF SETS
If A1, A2, …, Am are finite sets, then the number of
elements in the Cartesian product of these sets is the
product of the number of elements in each set.
16
EXERCISE
Find the number n of ways that an organization consisting of
15 members can elect a president, treasurer, and secretary.
(assuming no person is elected to more than one position)
SOLUTION:
The president can be elected in 15 different ways;
The treasurer can be elected in 14 different ways;
The secretary can be elected in 13 different ways.
Thus, by product rule, there are
n = 15 x 14 x 13 = 2730
different ways in which the organization can elect the officers.
17
EXERCISE
There are four bus lines between A and B; and three bus
lines between B and C.
18
SOLUTION
(a) There are 4 ways to go from A to B and 3 ways to go from B
to C;
hence there are
4 x 3 = 12 ways to go from A to C by way of B.
4 3 2 3
i.e., A→ B → C → B → A
20
EXERCISE
How many bit strings of length 8
21
SOLUTION
(i) If the first bit (left most bit) is a 1, then it can be filled in
only one way.
Hence,
there are 1 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 27 = 128
different bit strings of length 8 that begin with a 1.
22
(ii) If the first and last bit in an 8 bit string is a 1, then only
the intermediate six bits can be filled in 2 ways, i.e. by a 0
or 1.
23
EXERCISE
Suppose that an automobile license plate has three letters
followed by three digits.
24
SOLUTION
Each of the three letters can be written in 26 different
ways, and each of the three digits can be written in 10
different ways.
letters digits
25
(b) How many license plates could begin with A and end on
0?
SOLUTION:
The first and last place can be filled in one way only, while
each of second and third place can be filled in 26 ways
and each of fourth and fifth place can be filled in 10 ways.
letters digits
A 0
27
SOLUTION
First consider variable names one character in length.
Since such names consist of a single letter, there are 26
variable names of length 1.
29
SOLUTION
Number of code words of length 1 = 261
Number of code words of length 2 = 262
Number of code words of length 3 = 263
30