Counting Theory Zalak
Counting Theory Zalak
Counting Theory Zalak
Mathematics
COUNTING
Dr. Zalak A. Patel
Asst. Professor, Mathematics
L. D. College Of Engineering
The Product Rule
Suppose that a Procedure can be broken
down into a sequence of two tasks.
123 4 5 6 1 2 3 4 56
How about
Letter Digit Letter Digit Letter Digit?
Answer: 26
Problem : Telephone Numbering Plan
If the telephone numbers of specific city
has format NYX-NNX-XXXX (Area Code –
office code – station code), where N
denotes the digits 2 to 9, X denotes the d
igits 0 to 9,and Y must be either 0 or 1, th
en how many different numbers are pos
sible under the said plan?
Telephone Numbering Plan
Under scheme NYX-NNX-XXXX,
Area code NYX : 8 . 2. 10 =160
Office code NNX : 8. 8. 10 = 800
Station code XXXX : 10. 10. 10 = 1000
Total possible numbers are,
NYX-NNX-XXXX = 160. 800. 1000
= 1,024,000,000 .
Cartesian Products & Strings
Then:
• A = 1 4 6 7, B = 2 4 5 7,
and C = 3 5 6 7.
Thus,
|A B C|
= |A| + |B| + |C| |AB| |AC| |BC|
+ |ABC|
= (1+4+6+7+2+4+5+7+3+5+6+7)
(475767) (+7)
= 1+2+3+4+5+6+7
• Example: The CS department teaches
Algol, Basic, and C languages.
Suppose:
– 22 students study Algol; 30 study Basic; 4
2 study C;
– 12 study Algol and Basic;
– 18 study Basic and C;
– 16 study Algol and C;
– 9 study all three.
• How many students study a language?
Answer:
57 = 22+30+42121816+9
Counting Elements in a List
Theorem: If m and n are integers with
m n, then there are (n m + 1) integers
from m to n.
Hence number of integers from 1 to 100
is 100 1 + 1 = 100.
Number of integers from 5 to 18 is
18 (5) + 1 = 24.
Counting Things Without a Condition
How many 3-digit integers are not divisible by
5?
Before, we saw that there are 180 3-digit int
egers which are divisible by 5,
hence: {all 3-digit integers not divisible by 5}
= {all 3-digit integers} {all 3-digit
integers divisible by 5}.
Therefore there are
(999 100 + 1) 180 = 720
3-digit integers which are not di
visible by 5.
Tree Diagramas
• How many bit strings of length four do not
have two consecutive 1s?
• A playoff between two teams consists of at
most five games. The first team that wins
three consecutive games wins the playoff.
In how many different ways can the
playoff occur?
The Division Rule
Theorem:
6! = 654321 = 720.
COMPUTER
Answer: 8! = 40,320
Counting Permutations
• How many orderings of the letters of the
word COMPUTER are there if the letters C
O must stay together in this order?
CO M P U T E R
Answer: 7! = 5,040
More Counting Permutations
• What is the probability of the CO will
appear in a given permutation of them
letters of COMPUTER?
D C C B B A A E E D
Partial Permutations
If we don’t want to list out all n elements in
a linear permutation. Suppose we only wan
t the first r elements, for r < n.
Total = n!/(nr)!
We denote the partial permutation P(n,r).
Partial Permutations
Theorem:
P(n,r) = n(n1)...(nr+1) = n!/(nr)!
How many 5-letter strings can be formed
from the letters of COMPUTER?
Answer: P(8,5) = 8!/(85)! = 8!/3!
= 87654
Evaluating Partial Permutations
How many 6-character license plates can
be made if a character can be a letter or
digit, but no character can repeat?
Answer:
C(5,3)C(7,2) = [5!/(3!2!)][7!/(5!2!)]
= 7!/(3!2!2!).
• How many teams have at least 1 man?
(All teams w/no man)
= C(12,5) C(7,5)
= [12!/(7!5!)] [7!/(5!2!)]
• How many teams have at most 1 man?
(teams w/no man) + (teams w/1 man)
= C(7,5) + C(5,1)C(7,4)
= 7!/(5!2!) + [5!/4!][7!/(3!4!)]
Generalized Permutations
Example:
we learned how to count the number of orderings
of the letters of COMPUTER.
In this case, we note that not all the letters are
distinct.
What about the number of orderings of the letters
of MISSISSIPPI?
• In particular,
for word MISSISSIPPI, number of linear
arrangements are 11!, Out of which
for letter S the same arrangements are 4!
for letter I the same arrangements are 4!
for letter P the same arrangements are 2!
for letter M the same arrangements are 1!
This leaves us with a total count of 11!/4!4!2!.
Generalized Permutations
• Modelling this problem, purely as a combination
and not a permutation at all, we can reason the
task as:
1. Choose 4 slots from 11 for the I’s;
2. Choose 4 slots from the remaining 7
for the S’s;
3. Choose 2 slots from the remaining 3
for the P’s;
4. Place the M (only 1 way remaining).
with this answer is
C(11,4)C(7,4)C(3,2)C(1,1)
=(11!7!3!)/(7!4!4!3!2!1!)
= 11!/(4!4!2!).
• This leads us to state a theorem…
Generalized Permutation Theorem
• Theorem:
Suppose a collection consists of n objects
of which: n1 are of type 1, indistinguishable
from each other; n2 are of type 2, indistingui
shable from each other; ... nk are of type k,
indistinguishable from each other;
and n1 + n2 + ... + nk = n, then the number
of distinct permutations of the n objects is:
C(n,n1)C(nn1,n2)C(nn1n2,n3)...C(nk,nk)
=n! / (n1!n2!n3!...nk!).
Combinations with Repetition
• In the last section, we saw how to count
combinations, where order does not matter,
based on permutation counts, and we saw
how to count permutations where repetitions
occur.
• Now, we shall consider the case where
we don’t want order to matter, but we will
allow repetitions to occur.
• This will complete the matrix of counting
formulae, indexed by order and repetition.
Counting Generalized Combinations
Theorem:
The number of ways to fill r slots from
n categories with repetition allowed is:
C(r + n 1, r) = C(r + n 1, n 1).