Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
170 views

Unit 5 - Counting and Discrete Probability - Complete

This document discusses counting principles including the product rule, sum rule, and pigeonhole principle. 1) The product rule states that if a task can be broken into independent subtasks, the total number of ways to complete the task is the product of the number of ways to complete each subtask. 2) The sum rule states that if a task can be completed by completing exactly one of several mutually exclusive subtasks, the total number of ways is the sum of the number of ways to complete each subtask. 3) The pigeonhole principle states that if more objects are placed in fewer boxes, then at least one box must contain multiple objects.

Uploaded by

suman panta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

Unit 5 - Counting and Discrete Probability - Complete

This document discusses counting principles including the product rule, sum rule, and pigeonhole principle. 1) The product rule states that if a task can be broken into independent subtasks, the total number of ways to complete the task is the product of the number of ways to complete each subtask. 2) The sum rule states that if a task can be completed by completing exactly one of several mutually exclusive subtasks, the total number of ways is the sum of the number of ways to complete each subtask. 3) The pigeonhole principle states that if more objects are placed in fewer boxes, then at least one box must contain multiple objects.

Uploaded by

suman panta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

UNIT 5.

COUNTING AND DISCRETE PROBABILITY 1

Unit 5

Counting and Discrete Probability

5.1 Counting

5.1.1 Basics of Counting


We study two of the most elementary methods of counting: the product rule and the sum rule.
These rule are applied when we can divide the sets or tasks under study into a finite number of
subsets or subtasks.
I. The Product Rule: Suppose that a task T can be broken down into n subtasks T1 , T2 , · · · , Tn
and suppose that the task T is completed when all the subtasks T1 , · · · , Tn are completed. If the
task Ti can be completed in ki ways for each i = 1, · · · , n, then the product rule says that the
task T can be completed in k1 k2 · · · kn ways.
Examples:

1. If two cards are drawn, each from a separate deck of 52 cards, then in how many ways
can they be selected?
Solution: Here,

number of ways to draw the first card= k1 = 52


number of ways to draw the second card= k2 = 52.

Since both the first and the second cards have to be drawn, so by product rule, two cards
can be drawn in k1 × k2 = 52 × 52 = 2704 ways.

2. How many 3-digit numbers can be formed using the digits 1, 3, 4, 5, 6, 8 and 9 with repe-
tition allowed and not allowed?
Solution: When repetition is allowed,

number of ways to select the first digit= k1 = 7


number of ways to select the second digit= k2 = 7
number of ways to select the third digit= k3 = 7.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 2

Since all three digits have to be selected to form 3-digit number, so by product rule, a
3-digit number with repetition allowed can be formed in k1 k2 k3 = 7 × 7 × 7 = 343 ways.
When repetition is not allowed,

number of ways to select the first digit= k1 = 7


number of ways to select the second digit= k2 = 6
number of ways to select the third digit= k3 = 5.

So again by product rule, a 3-digit number without repetition can be formed in k1 k2 k3 =


7 × 6 × 5 = 210 ways.

3. How many different bit strings are there of length six?


Solution: Here,

number of ways to select the 1st digit= k1 = 2


number of ways to select the 2nd digit= k2 = 2.
number of ways to select the 3rd digit= k3 = 2.
number of ways to select the 4th digit= k4 = 2.
number of ways to select the 5th digit= k5 = 2.
number of ways to select the 6th digit= k6 = 2.

So by the product rule, there are

2 × 2 × 2 × 2 × 2 × 2 = 26 = 64

bit strings of length six.

4. How many bit strings of length ten begin and end with a 1?
Solution: To form a bit string of length ten that ends with a 1, there are 2 ways to select
the second to the ninth digit and 1 way to select the first and tenth digit. So using the
product rule, there are

1 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 1 = 256

bit strings of length ten that begin and end with a 1.

II. The Sum Rule: Suppose that a task T can be broken into n disjoint subtasks T1 , T2 , · · · , Tn
i.e., none of the subtasks in T1 , · · · , Tn are same. Also suppose that the task T is completed
when exactly one among the subtasks T1 , · · · , Tn is completed. If the task Ti can be completed
in ki ways for each i = 1, · · · , n, then the sum rule says that the task T can be completed in
k1 + k2 + · · · + kn ways.
Examples:

1. In how many ways can one representative be chosen from classes 11 and 12 consisting of
49 and 34 students respectively?
Solution: Here

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 3

number of ways to select one representative from class 11 = k1 = 49


number of ways to select one representative from class 12 = k2 = 34.

So by sum rule, number of ways to select one representative either from class 11 or class
12 is k1 + k2 = 49 + 34 = 83 ways.

2. (Example using the combined rules of sum and product) How many license plates can
be made using either two letters followed by four digits or two digits followed by four
letters?
Solution: By the product rule, the number of license plates with two letters followed by
four digits is
26 × 26 × 10 × 10 × 10 × 10 = 6760000
and the number of license plates with two digits followed by four letters is

10 × 10 × 26 × 26 × 26 × 26 = 45697600.

Since license plates can be one of these two types, so by the sum rule, the total number
of such license plates is

6760000 + 45697600 = 52457600.

5.1.2 Pigeonhole Principle


Theorem (The Pigeonhole Principle): If k + 1 or more objects are placed into k boxes, then
there is at least one box containing two or more of the objects.
Proof: Suppose that k + 1 or more objects are placed into k boxes but that none of the boxes
contain two or more of the objects i.e., all of the k boxes contain at most one object. This
implies that there are at most k objects which is a contradiction because there were at least
k + 1 objects. Therefore, at least one box must contain two or more objects.
Examples:

1. If a classroom has 8 students, then at least two of them must have birthdays on the same
weekday. To see why, consider the students as the objects and the 7 weekdays as the
boxes. Since the birthday of each of the 8 students must be on one of these 7 weekdays
and there are more students than number of weekdays, so by the pigeonhole principle,
there must be at least one weekday in which two of more students have their birthdays.

2. If any five distinct numbers are chosen from 1 to 8, then two of them must add to 9.
Explanation: There are only 4 ways to choose a pair of numbers from 1 to 8 so that they
add up to 9: {1, 8}, {2, 7}, {3, 6}, {4, 5}. Consider these as boxes. Now choose any five
numbers from 1 to 8. Consider these as objects. So there are more number of objects than
boxes. Since each of the five numbers chosen must belong to one of the above four pairs,
the pigeonhole principle tells us that two of the chosen numbers must belong to the same
pair i.e., the sum of those two numbers must be 9.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 4

3. If f : S → T is a function where |S| > |T |, then f cannot be one-to-one.


Explanation: Consider the elements of S as the objects and the elements of T as the boxes.
Since |S| > |T |, so the number of objects is greater than the number of boxes. Since the
function f assigns the elements of S to the elements of T and there are more elements in
S than in T , so by the pigeonhole principle, f must assign at least two elements of S to
the same element of T . Thus f cannot be one-to-one.

Theorem (The Generalized Pigeonhole   Principle): If N objects are placed in k boxes, then
N
there is at least one box containing or more objects.
k
Proof: The proof is  bycontradiction. Suppose N objects are placed in k boxes  but
 that none of
N N
the boxes contain or more objects i.e., all the boxes contains at most − 1 objects.
k    k
N
So the total number of objects is at most k − 1 . But since dxe < x + 1 so
k
     
N N
k −1 <k + 1 − 1 = N.
k k
That is, the total number of objects is less than N which isfalse
 because there were N number
N
of objects given. Therefore, at least one box must contain or more objects.
k
Note: If a number of objects are to be distributed in k boxes such that there is guarantee that at
least one box has m or more objects, then the minimum number of objects required is

k(m − 1) + 1.

Examples:

1. If 30 dictionaries in a library contains a total of 61327 pages, then how many minimum
pages at least one dictionary must have?
Solution: Here

total number of pages= N = 61327


total number of dictionaries= k = 30

So by generalized pigeonhole principle, at least one dictionary must have a minimum of


 
61327
= d2044.23e = 2045
30
pages.

2. In a group of 61 people, at least how many of them must have birthdays on the same
month?
Solution: Here,

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 5

total number of people= N = 61


total number of months= k = 12.

So by generalized pigeonhole principle, at least


 
61
= d5.08e = 6
12
people must have their birthdays on the same month.
3. How many students must be in a class to guarantee that at least two students receive the
same score on the final exam if the exam is graded on a scale from 0 to 100 points?
Solution: Here,

total number of possible scores= k = 101


minimum number of students to receive the same score= m = 2.

So to guarantee that at least two students receive the same score, the class must have
minimum of k(m − 1) + 1 = 101(2 − 1) + 1 = 102 students.
4. How many numbers must be selected from the set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} to guarantee
that at least one pair of these numbers add up to 11?
Solution: The pair of numbers that add up to 11 are {1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}.
So

total number of possible pairs of numbers= k = 5


number of numbers to be in same pair= m = 2.

So to guarantee that at least one pair of these numbers add up to 11, we must select
minimum of k(m − 1) + 1 = 5(2 − 1) + 1 = 6 numbers.
5. Find the minimum number of people in a group to be sure that three of them are born on
the same month.
Solution: Here,

total number of months= k = 12


number of people to be born on same month= m = 3

So minimum number of people required in the group is


k(m − 1) + 1 = 12(3 − 1) + 1 = 25.

6. Find the minimum number of students to guarantee that 50 of them obtain a same grade
where there are altogether 20 grades.
Solution: Here,

total number of grades available= k = 20


minimum number of students to get same grade= m = 50.

So the required minimum number of students in the class is k(m − 1) + 1 = 20(50 − 1) +


1 = 981.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 6

5.1.3 Permutations and Combinations


Permutation: The permutation of n distinct objects taken r at a time (also called an r-permutation
of n objects) is an ordered arrangement of r of the objects. The number of r-permutations of
n-objects is denoted by P (n, r).
For example, in the set {a, b, c} consisting of three distinct objects, the 2-permutations are
ab, ba, bc, cb, ac, ca. So P (3, 2) = 6.
Theorem: The number of r-permutations of a set with n distinct elements is
n!
P (n, r) = .
(n − r)!

Proof: Since there are n distinct elements, the first element can be chosen in n ways. Then
there are n − 1 elements left from which the second element can be chosen i.e., there are n − 1
ways to choose the second element. Similarly, there are n − 2 ways to choose the third element
and proceeding similarly, there are n − r + 1 ways to choose the rth element. Therefore by
product rule, there are n(n − 1)(n − 2) · · · (n − r + 1) ways to choose r elements from the set
of n elements i.e.,
P (n, r) = n(n − 1)(n − 2) · · · (n − r + 1)
n(n − 1)(n − 2) · · · (n − r + 1)(n − r)! n!
= =
(n − r)! (n − r)!

Examples:

1. How many license plates of 4 different digits can be formed?


Solution: We have

number of digits= n = 10,


number of digits to be selected= r = 4.

So the number of license plates of 4 different digits is


10! 10!
P (10, 4) = = = 10 × 9 × 8 × 7 = 5040.
(10 − 4)! 6!

2. How many permutation of the letters A, B, C, D, E, F, G, H contain


a. the string CDE?
Solution: Since CDE must appear as a block, it can be treated as a single letter. So
the total number of letters n = 6 (which are A, B, CDE, F, G, H) and the letters to
be selected r = 6. This can be done in
6! 720
P (6, 6) = = = 720
(6 − 6)! 1
ways.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 7

b. the strings BA and FGH?


Solution: Since BA must appear as a block, it can be treated as a single letter and
for the same reason, FGH can be treated as a single letter as well. So the problem
reduces to finding the number of permutations of n = 5 letters, namely BA, C, D,
E, FGH taken r = 5 at a time. This can be done in

P (5, 5) = 5! = 120

ways.

3. How many permutations of the letters A, B, C, D, E, F, G, H are possible so that the letters
D, E and F are adjacent?
Solution: There are P (3, 3) = 3! ways of arranging the letters D, E and F. For each such
arrangement, there are P (6, 6) = 6! ways of arranging the letters A, B, C, G, H, X where
X denotes the arrangement of D, E, F. So there are a total of

3! × 6! = 6 × 720 = 4320

permutations of the letters A, B, C, D, E, F, G, H so that the letters D, E and F are adjacent.

Combination: The combination of n distinct objects taken r at a time (also called an r-


combination of n objects) is an unordered selection  of r of the objects. The number of r-
n
combinations of n objects is denoted by C(n, r) or .
r
Since r-combinations differ from one another only when the objects in them are different, so it
can be interpreted as an r element subset of a set consisting of n elements and C(n, r) can be
interpreted as the number of r element subsets of a set containing n elements.
For example, in the set {a, b, c} consisting of three distinct objects, the 2-combinations are
ab, bc, ca. So C(3, 2) = 3.
Theorem: The number of r-combinations of a set with n distinct elements is
n!
C(n, r) = .
r!(n − r)!

Proof: The r-permutations of the set can be obtained by first forming the C(n, r) number of
r-combinations of the set and then ordering the elements in each r-combination which can be
done in P (r, r) ways. Therefore

P (n, r) = C(n, r)P (n, r)


n!
P (n, r) (n − r)! n!
or, C(n, r) = = =
P (r, r) r! r!(n − r)!
(r − r)!
n!
Therefore, C(n, r) = .
r!(n − r)!

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 8

Corollary: C(n, 0) = C(n, n) = 1 for any integer n ≥ 1.


Proof:
n! n! n!
C(n, 0) = = = =1
0!(n − 0)! 0!n! n!
n! n! n!
C(n, n) = = = =1
n!(n − n)! n!0! n!

Corollary: C(n, r) = C(n, n − r).


Proof: From the theorem, we have
n! n! n!
C(n, r) = = = = C(n, n − r).
r!(n − r)! [n − (n − r)]!(n − r)! (n − r)![n − (n − r)]!

Pascal’s Identity: C(n, r) + C(n, r − 1) = C(n + 1, r).


Proof: We have
n! n!
C(n, r) + C(n, r − 1) = +
r!(n − r)! (r − 1)!(n − r + 1)!
 
n! 1 1
= +
(r − 1)!(n − r)! r (n − r + 1)
 
n! n−r+1+r
=
(r − 1)!(n − r)! r(n − r + 1)
n! n+1
= ×
(r − 1)!(n − r)! r(n − r + 1)
(n + 1)!
=
r!(n − r + 1)!
(n + 1)!
=
r!(n + 1 − r)!
= C(n + 1, r)

Pascal’s Triangle: The arrangement of the binomial coefficients in triangular form as below is
called Pascal’s triangle.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 9

As is clearly seen in the figure above, the inner elements in each row of Pascal’s triangle is
obtained by applying the Pascal’s identity on the two elements above it.
Example:

1. How many ways are there to form a 6-member committee from 20 people?
Solution: We have

total number of people= n = 20,


number of members to be selected= r = 6.

So the number of 6-member committee that can be formed is


20! 20!
C(20, 6) = = = 38760.
6!(20 − 6)! 6!14!

2. How many ways are there to form a 7-member committee containing 3 women and 4 men
from an available set of 20 women and 30 men?
Solution: We have,

number of ways to select 3 women from 20 women = C(20, 3) = 1140


number of ways to select 4 men from 30 men = C(30, 4) = 27405.

So by the product rule, there are


1140 × 27405 = 31241700
ways to form the required 7-member committee.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 10

3. How many bit strings of length 10 contain

a. exactly four 1’s?


Solution: We number the bit positions of a 10-bit string by numbers 1 to 10 and
select any 4 of those positions. In these selected positions, we fill in 1 and in others
we fill 0. So we see that the number of bit strings containing exactly four 1’s is equal
to C(10, 4) = 210.
b. at most four 1’s?
Solution: A length 10 bit string that has
0 number of 1’s is C(10, 0) = 1,
1 number of 1’s is C(10, 1) = 10,
2 number of 1’s is C(10, 2) = 45,
3 number of 1’s is C(10, 3) = 120,
4 number of 1’s is C(10, 4) = 210.
Therefore the total number of bit strings of length 10 having at most four 1’s is

1 + 10 + 45 + 120 + 210 = 386.

c. at least four 1’s?


Solution: A length 10 bit string that has
4 number of 1’s is C(10, 4) = 210,
5 number of 1’s is C(10, 5) = 252,
6 number of 1’s is C(10, 6) = 210,
7 number of 1’s is C(10, 7) = 120,
8 number of 1’s is C(10, 8) = 45,
9 number of 1’s is C(10, 9) = 10,
10 number of 1’s is C(10, 10) = 1.
Therefore the total number of bit strings of length 10 having at least four 1’s is

210 + 252 + 210 + 120 + 45 + 10 + 1 = 848.

d. an equal number of 0’s and 1’s?


Solution: A length 10 bit string that has equal number of 0’s and 1’s has exactly five
0’s. The number of such bit strings is

C(10, 5) = 252.

5.1.4 Binomial Coefficients


Binomial Theorem: Let x and y be variables and let n ≥ 1 be an integer. Then
n  
n
X n
(x + y) = xn−r y r .
r
r=0

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 11

k-th term in a binomial expansion of (x+y)n : There are altogether n+1 terms in the binomial
expansion of (x + y)n . The general term of this expansion is of the form
 
n
xn−r y r
r

where r can change from 0 to n. When r = 0, one gets the first term; when r = 1, one gets the
second term and so on. So the k term is obtained when r = k − 1 which is
 
n
xn−(k−1) y k−1 .
k−1

Middle terms in the binomial expansion of (x + y)n : If n is even,then 


there is exactly one
n n n
middle term in the expansion of (x + y)n , namely the n2 + 1-th term: n x2y2.
2
n n−1
If n is odd, then there are two middle terms in the expansion of (x + y) , namely the 2
+ 1-th
term and n+12
+ 1-th terms:
   
n n− n−1 n−1 n n+1 n−1
n−1 x 2 y 2 = n−1 x 2 y 2
2 2

and    
n n− n+1 n+1 n n−1 n+1
n+1 x 2 y 2 = n+1 x 2 y 2 .
2 2
 
n
Binomial Coefficients: The number of r-combinations of n elements i.e., occur as
r
coefficients in the expansion of the binomial expressions such as (a + b)n . Therefore such
numbers are called binomial coefficients.
Corollary 1: Let n be a nonnegative integer. Then
n  
X n
= 2n .
k
k=0

Proof: From the binomial theorem, we have


n  
X
n n
(x + y) = xn−k y k .
k
k=0

Let x = 1 and y = 1. Then


n  
X
n n
(1 + 1) = 1n−k 1k .
k
k=0

n  
n
X n
or, 2 = .
k
k=0

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 12

n  
X
k n
Corollary 2: Let n be a positive integer. Then (−1) = 0.
k
k=0
Proof: From the binomial theorem, we know
n  
n
X n
(x + y) = xn−k y k .
k
k=0

Let x = 1 and y = −1. Then


n  
X
n n
(1 + (−1)) = 1n−k (−1)k
k
k=0

n  
X n
or, 0 = (−1)k
k
k=0
n  
X n
Therefore, (−1)k = 0.
k
k=0
n  
X
k n
Corollary 3: Let n be a nonnegative integer. Then 2 = 3n .
k
k=0
Proof: From the binomial theorem, we have
n  
n
X n
(x + y) = xn−k y k .
k
k=0

Let x = 1 and y = 2. Then


n  
n
X n
(1 + 2) = 1n−k 2k
k
k=0
n  
n
X n
or, 3 = 2k
k
k=0
n  
X n
Therefore, 2k = 3n .
k
k=0

5.1.5 Generalized Permutations and Combinations


Permutation with repetition: Given n distinct objects, one can take ordered arrangement of r
of those objects where those r objects are allowed to repeat. Such kind of permutation is known
as r-permutation with repetition.
For example, if a, b, c are three objects, then the 2-permutations of these objects with repetition
allowed are aa, ab, ba, bb, ca, cc, ac, bc, cb. These are 32 = 9 in number.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 13

Theorem 1: The number of r-permutations of a set of n objects with repetition allowed is nr .


Example:

1. How many license plates of 4 digits can be formed?


Solution: We have

number of digits= n = 10,


number of digits to be selected= r = 4.

So the number of license plates of 4 digits is


nr = 104 = 10000.

Combination with repetition: Given n distinct objects, one can take unordered arrangement
of r of those objects where those r objects are allowed to repeat. Such kind of combination is
known as r-combination with repetition.
For example, given three distinct objects a, b, c, the 2-combinations of these objects with repe-
tition allowed are aa, ab, bb, ba, cc, ca. These are C(3 + 2 − 1, 2) = C(4, 2) = 6 in number.
Theorem 2: The number of r-combinations of a set of n objects with repetition allowed is
C(n + r − 1, r).
Example:

1. Suppose that a library contains Maths, Physics and Chemistry books. If a student has to
select 6 books from the library, in how many ways can he/she do this without concerning
about the order of chosen books assuming that there are at least 6 copies of each book?
Solution: Here,

number of distinct objects, i.e., books available is n = 3


number of book to select r = 6

This can be done in


C(n + r − 1, r) = C(3 + 6 − 1, 6) = C(8, 6) = 28
ways.

Permutation with indistinguishable objects: When there are n given objects which are not
necessarily distinct, then the permutation of those objects is called permutation with indis-
tinguishable objects. The number of possible permutations of those objects is given by the
following theorem:
Theorem 3: The number of different permutations of n objects where there are n1 indistin-
guishable objects of type 1, n2 indistinguishable objects of type 2 and so on nk indistinguishable
objects of type k, is given by
n!
.
n1 !n2 ! · · · nk !
Example:

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 14

1. How many distinct permutations can be formed from all the letters of the word EV ERGREEN ?
Solution: The total number of letters in the word EVERGREEN is n = 9 where

the number of letters E = n1 = 4


the number of letters V = n2 = 1
the number of letters R = n3 = 2
the number of letters G = n4 = 1
the number of letters N = n5 = 1

Therefore the number of distinct permutations is


9!
= 7560.
4! 1! 2! 1! 1!

Circular Permutation: The circular permutation of n distinct objects is an ordered arrange-


ment (without repetition) of those objects in a circle.
In an ordinary (or linear) permutation, we get different permutations when the objects are ar-
ranged in different order. But in circular permutation, different permutations are obtained only
when relative order of the objects are changed in the arrangement. For example, if three objects
A, B, C are taken, then their circular permutations are ABC and ACB only. The arrangements
BCA and CAB are the same as the arrangement ABC when viewed as circular permutations.
Similarly, BAC and CBA are same as ACB when viewed as circular permutations.

Theorem 4: The number of circular permutations of n distinct objects in (n − 1)!.


Example:

1. In how many ways can 6 people be seated in a round table?


Solution: The number of people to be seated in a round table is n = 6. This can be done
in
(n − 1)! = (6 − 1)! = 5! = 120
ways.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 15

5.2 Advanced Counting

5.2.1 Recurrence Relations


Recurrence relation: A recurrence relation for the sequence {an } is an equation that expresses
an , where n ≥ n0 for some nonnegative integer n0 , in terms of one or more of the previous
terms of the sequence, namely, a0 , a1 , · · · , an−1 .
For example, the sequence 1, 4, 7, 10, 13, · · · can be expressed using a recursive relation as
an = an−1 + 3, n ≥ 1, a0 = 1.
Solution of a recurrence relation: A sequence whose terms satisfies the recurrence relation is
called a solution of that recurrence relation.
For example, the sequence {an } where an = 3n , satisfies the recurrence relation an = 3an−1
because an = 3n = 3.3n−1 = 3an−1 i.e., the given sequence satisfies the given recurrence
relation.
Problems:

1. Find the first five terms of the sequence defined by the recurrence relation an = nan−1 +
a2n−2 , a0 = −1, a1 = 0.
Solution: Here, the given recurrence relation is

an = nan−1 + a2n−2 , a0 = −1, a1 = 0

So

a2 = 2a2−1 + a22−2 = 2a1 + a20 = 1


a3 = 3a3−1 + a23−2 = 3a2 + a21 = 3
a4 = 4a4−1 + a24−2 = 4a3 + a22 = 13
a5 = 5a5−1 + a25−2 = 5a4 + a23 = 74

2. Determine whether the sequences {an } given below are the solutions of the recurrence
relation an = 8an−1 − 16an−2 .
a. an = 4n b. an = (−4)n c. an = 2.4n + 3n4n
Solution:
a. We have an = 4n . So an−1 = 4n−1 and an−2 = 4n−2 . Therefore

8an−1 − 16an−2 = 8.4n−1 − 16.4n−2 = 4n−2 (8.4 − 16) = 4n−2 .16 = 4n = an .

So an = 4n is a solution of the given recurrence relation.


b. When an = (−4)n , then an−1 = (−4)n−1 and an−2 = (−4)n−2 . Therefore

8an−1 − 16an−2 = 8.(−4)n−1 − 16.(−4)n−2 = (−4)n−2 (8. − 4 − 16)

= (−4)n−2 (−32 − 16) = (−4)n−2 . − 48 = −3(−4)n−2 .16 = −3(−4)n 6= an .

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 16

So an = (−4)n is not a solution of the given recurrence relation.


c. When an = 4n (2 + 3n), we have an−1 = 4n−1 (2 + 3(n − 1)) = (3n − 1)4n−1 and
an−2 = 4n−2 (2 + 3(n − 2)) = (3n − 4)4n−2 . So
RHS = 8an−1 − 16an−2 = 8(3n − 1)4n−1 − 16(3n − 4)4n−2
= 2(3n − 1)4n − (3n − 4)4n = 4n (6n − 2 − 3n + 4) = 4n (2 + 3n) = an = LHS.
Therefore an = 4n (2 + 3n) is a solution of the given recurrence relation.

3. Find a recurrence relation satisfied by the following sequence:


(A) 3, 8, 13, 18, 23, · · ·
Solution: We have
a1 =3
a2 = 8 = 3 + 5 = a1 + 5
a3 = 13 = 8 + 5 = a2 + 5
a4 = 18 = 13 + 5 = a3 + 5
a5 = 23 = 18 + 5 = a4 + 5

Therefore the required recurrence relation is an = an−1 + 5, with a1 = 3.


(B) an = n2
Solution: We have an = n2 . So

an−1 = (n − 1)2 = n2 − 2n + 1 = an − 2n + 1

and therefore
an = an−1 + 2n − 1
is the required recurrence relation.

4. Solve the following recurrence relations using iterative methods:

a. an = an−1 + 3, a0 = 1
Solution: We have,

an = an−1 + 3
= (an−2 + 3) + 3 = an−2 + 2 × 3
= (an−3 + 3) + 2 × 3 = an−3 + 3 × 3
..
.
= an−n + n × 3
= a0 + 3n = 1 + 3n

Hence an = 1 + 3n, n ≥ 0 is the solution of the given recurrence relation.


b. an = 2nan−1 , a0 = 1

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 17

Solution: We have,

an = 2nan−1
= 2n(2(n − 1)an−2 ) = 22 n(n − 1)an−2
= 22 n(n − 1)(2(n − 2)an−3 ) = 23 n(n − 1)(n − 2)an−3
..
.
= 2n n(n − 1)(n − 2) · · · [n − (n − 1)]an−n
= 2n n(n − 1)(n − 2) · · · 3.2.1.a0
= 2n n!.1 = 2n n!

Therefore, an = 2n n!, n ≥ 0 is the solution of the given recurrence relation.


c. an = nan−1 , a0 = 5
d. an = 2an−1 − 3, a0 = −1
e. an = an−1 + n2 , a0 = 7
f. an = an−1 + 3n , a0 = 1
an−1
g. an = , a1 = 1
n

Modeling with recurrence relations:


Recurrence relations can be used to solve seemingly difficult counting problems which occur
frequently in many situations. To solve such problems, the problem is first of all modeled using
a recurrence relation and that recurrence relation is then solved to obtain the required answer.

1. The tower of Hanoi problem: There are three poles and n disks of different diameters
placed on the pole A. These n disks are to be moved to the pole C with same order of
arrangement of disks and obeying the following rules:

i. only one disk may be moved at a time


ii. pole B may be used for temporary storage of disks
iii. no disk should ever be placed on top of a disk of smaller diameter

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 18

Find the number of moves required to move all n disks from pole A to pole C.
Solution: Let Hn denote the number of moves needed to solve the tower of Hanoi prob-
lem with n disks. Then to transfer n disks to pole C, we must first transfer the top n − 1
disks to pole B (this requires Hn−1 moves), transfer the remaining largest disk from pole
A to pole C (this requires 1 move) and then transfer n − 1 disks from pole B to pole C
(this again requires Hn−1 moves). Therefore,

Hn = Hn−1 + 1 + Hn−1 = 2hn−1 + 1.

Also, the number of moves required to transfer 1 disk from pole A to pole B is 1 i.e.,
H1 = 1. So we obtain the recurrence relation

Hn = 2Hn−1 + 1, H1 = 1.

We solve this recurrence relation iteratively as follows:

Hn = 2Hn−1 + 1
= 2[2Hn−2 + 1] + 1 = 22 Hn−2 + 2 + 1
= 22 [2Hn−3 + 1] + 2 + 1 = 23 Hn−3 + 22 + 2 + 1
..
.
= 2n−1 Hn−(n−1) + 2n−2 + · · · + 2 + 1
= 2n−1 H1 + 2n−2 + · · · + 2 + 1
= 2n−1 + 2n−2 + · · · + 2 + 1
2n − 1
= = 2n − 1
2−1
Therefore Hn = 2n − 1.

2. Find a recurrence relation and give initial conditions for the number of bit strings of length
n that do not have two consecutive zeros.
Solution: Let an denote the number of bit strings of length n that do not have two con-
secutive zeros. Then an = bn + cn where bn is the number of bit strings of length n that
do not have two consecutive zeros and ends with a 1 and cn is the number of bit strings of
length n that do not have two consecutive zeros and ends with a 0.
Now x = x1 x2 · · · xn−1 xn is a bit string of length n ending with a 1 that does not contain
two consecutive zeros if and only if x1 x2 · · · xn−1 does not contain two consecutive zeros.
Therefore bn = an−1 . Also x = x1 x2 · · · xn−1 xn is a bit string of length n ending with a
0 that do not have two consecutive zeros if and only if xn−1 = 1 and x1 x2 · · · xn−2 does
not have two consecutive zeros. Therefore cn = bn−1 = an−2 . Hence an = bn + cn =
an−1 + an−2 . Clearly, a1 = 2 and a2 = 3 which are the required initial conditions.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 19

3. Compound Interest Problem: If a principal of amount P0 = 10000 is deposited in an


account which gives an annual compound interest rate of 11%, then what would be the
amount after N years?
Solution: If PN denotes the amount after N number of years, then this amount is what
we get after adding 11% interest to the amount that was at the end of N − 1 number of
years i.e.,
11 111
PN = PN −1 + PN −1 = PN −1
100 100
which is a recurrence relation with initial condition P0 = 10000. We can solve this
recurrence relation using the back substitution method as follows:
 2  N  N  N
111 111 111 111 111
PN = PN −1 = PN −2 = · · · = PN −N = P0 = 10000.
100 100 100 100 100

5.2.2 Solving Homogeneous Recurrence Relations


Linear homogeneous recurrence relation: A linear homogeneous recurrence relation of de-
gree k with constant coefficients is a recurrence relation of the form

an = c1 an−1 + c2 an−2 + · · · + ck an−k

where c1 , · · · , ck are constants and ck 6= 0.


For example, an = an−1 + 2an−2 is a linear homogeneous recurrence relation of degree 2,
an = 4an−2 is also a linear homogeneous recurrence relation of degree 2. But an = 3an−1 −
3an−2 + an−3 is a linear homogeneous recurrence relation of degree 3.
Characteristic equations and characteristic roots: If

an = c1 an−1 + c2 an−2 + · · · + ck an−k , ck 6= 0

is a linear homogeneous recurrence relation of degree k, then the polynomial

rk − c1 rk−1 − c2 rk−2 − · · · − ck−1 r − ck = 0

is called the characteristic equation of this recurrence relation.


The solutions of the characteristic equation are called the characteristic roots of this recurrence
relation.
For example, an = an−1 + 2an−2 has characteristic equation r2 − r − 2 = 0 with characteristic
roots r1 = 2 and r2 = −1, an = 4an−2 has characteristic equation r2 −4 = 0 with characteristic
roots r1 = 2 and r2 = −2 and an = 3an−1 − 3an−2 + an−3 has characteristic equation r3 −
3r2 + 3r − 1 = 0 with characteristic roots r1 = 1, r2 = 1 and r3 = 1.
Theorem 1:(Statement only) Let c1 and c2 be real numbers. Suppose that r2 − c1 r − c2 = 0 has
two distinct roots r1 and r2 . Then the sequence {an } is a solution of the recurrence relation

an = c1 an−1 + c2 an−2

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 20

if and only if
an = α1 r1n + α2 r2n
for n = 0, 1, 2, · · · where α1 and α2 are constants.
Examples illustrating the use of Theorem 1:

1. Find the solution of the recurrence relation an = 5an−1 − 6an−2 , with a0 = 1 and a1 = 0.
Solution: Here the given recurrence relation is

an = 5an−1 − 6an−2 , a0 = 1 and a1 = 0 · · · · · · (1)

The characteristic equation of this recurrence relation is r2 − 5r + 6 = 0. Solutions of


this characteristic equation are r1 = 2 and r2 = 3. Therefore the solution {an } of the
recurrence relation (1) must be of the form

an = α1 r1n + α2 r2n

or, an = α1 2n + α2 3n · · · · · · (2)
where α1 and α2 are some constants.
When n = 0, equation (2) give
a0 = α 1 + α 2
or, 1 = α1 + α2 · · · · · · (3)
When n = 1, equation (2) gives

a1 = 2α1 + 3α2

or, 0 = 2α1 + 3α2 · · · · · · (4)


Solving equations (3) and (4), we get, α1 = 3 and α2 = −2. (DO THE DETAILS
YOURSELF) Therefore the solution {an } of the given recurrence relation is of the form
an = 3.2n − 2.3n .

2. Find an explicit formula for Fibonacci numbers. OR Solve the recurrence relation fn =
fn−1 + fn−2 with f0 = 0 and f1 = 1.
Solution: The recurrence relation representing the Fibonacci numbers is

fn = fn−1 + fn−2 , f0 = 0, f1 = 1 · · · · · · (1)

The characteristic equation associated


√ recurrence relation is r2 − r − 1 = 0
with this √
1+ 5 1− 5
whose solutions are r1 = and r2 = . Therefore the solution {an } of this
2 2
recurrence relation is of the form
√ !n √ !n
1+ 5 1− 5
fn = α1 + α2 · · · · · · (2)
2 2

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 21

where α1 and α2 are constants.


When n = 0, then equation (2) gives

f0 = α1 + α2

or, 0 = α1 + α2 · · · · · · (3)
and when n = 1, equation (2) gives
√ ! √ !
1+ 5 1− 5
f 1 = α1 + α2
2 2
√ ! √ !
1+ 5 1− 5
or, 1 = α1 + α2 · · · · · · (4)
2 2
1 −1
Solving (3) and (4), we get α1 = √ and α2 = √ . (DO THE DETAILS YOURSELF)
5 5
Hence the explicit formula for the Fibonacci numbers is
√ !n √ !n
1 1+ 5 1 1− 5
fn = √ −√ .
5 2 5 2

3. Find the solution of following recurrence relations:

a. an = an−1 + 6an−2 , a0 = 3, a1 = 6
b. an = 7an−1 − 10an−2 , a0 = 2, a1 = 1
c. an = 4an−2 , a0 = 0, a1 = 4

Theorem 2 (Generalization of Theorem 1): (Statement only) Let c1 , c2 , · · · , ck be real num-


bers. Suppose that the characteristic equation rk − c1 rk−1 − · · · − ck = 0 has k distinct roots
r1 , r2 , · · · , rk . Then a sequence {an } is a solution of the recurrence relation

an = c1 an−1 + c2 an−2 + · · · + ck an−l

if and only if
an = α1 r1n + α2 r2n + · · · + αk rkn
for n = 0, 1, 2, · · · where α1 , α2 , · · · , αk are constants.
Examples illustrating the use of Theorem 2:

1. Solve the recurrence relation an = 2an−1 + an−2 − 2an−3 with a0 = 3, a1 = 6 and a2 = 0.


Solution: The given recurrence relation is

an = 2an−1 + an−2 − 2an−3 , a0 = 3, a1 = 6, a2 = 0 · · · · · · (1)

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 22

The characteristic equation of this recurrence relation is

r3 − 2r2 − r + 2 = 0

or, r2 (r − 2) − 1(r − 2) = 0
or, (r2 − 1)(r − 2) = 0
or, (r − 1)(r + 1)(r − 2) = 0

So the characteristic roots are r1 = −1, r2 = 1 and r3 = 2. Therefore the solution {an }
of the recurrence relation must be of the form

an = α1 (−1)n + α2 1n + α3 2n

or, an = α1 (−1)n + α2 + α3 2n · · · · · · (2)


where α1 , α2 and α3 are constants.
When n = 0, equation (2) becomes

3 = α1 + α2 + α3 · · · · · · (3)

When n = 1, equation (2) becomes

6 = −α1 + α2 + 2α3 · · · · · · (4)

When n = 2, equation (2) becomes

0 = α1 + α2 + 4α3 · · · · · · (5)

Solving (3), (4) and (5), we get α1 = −2, α2 = 6 and α3 = −1. (DO THE DETAILS
YOURSELF) Hence the solution {an } of the recurrence relation (1) is of the form

an = −2(−1)n + 6 − 2n = 2(−1)n+1 − 2n + 6.

2. Solve the following recurrence relations:


a. an = 6an−1 − 11an−2 + 6an−3 with a0 = 2, a1 = 5, a2 = 15.
Hint: r3 − 6r2 + 11r − 6 = r3 − 5r2 + 6r − r2 + 5r − 6 = (r − 1)(r2 − 5r + 6)
b. an = 7an−2 + 6an−3 with a0 = 9, a1 = 10, a2 = 32.
Hint: r3 − 7r − 6 = r3 − r2 − 6r + r2 − r − 6 = (r + 1)(r2 − r − 6)

Theorem 3:(Statement only) Let c1 and c2 be real numbers with c2 6= 0. Suppose that r2 −
c1 r − c2 = 0 has only one root r0 . A sequence {an } is a solution of the recurrence relation

an = c1 an−1 + c2 an−2

if and only if
an = r0n (α1 + α2 n)
for n = 0, 1, 2, · · · where α1 and α2 are constants.
Examples illustrating the use of Theorem 3:

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 23

1. Find the solution of the recurrence relation an = 2an−1 − an−2 with a0 = 4, a1 = 1.


Solution: The given recurrence relation is
an = 2an−1 − an−2 , a0 = 4, a1 = 1 · · · · · · (1)
The characteristic equation of this recurrence relation is r2 − 2r + 1 = 0 whose only
solution is r0 = 1. Therefore the solution of this recurrence relation is of the form
an = r0n (α1 + α2 n)
or, an = 1n (α1 + α2 n)
or, an = α1 + α2 n · · · · · · (2)
where α1 and α2 are some constants.
When n = 0, equation (2) becomes
a0 = α1 + α2 .0
or, 4 = α1 · · · · · · (3)
and when n = 1, equation (2) becomes
a1 = α1 + α2 .1
or, 1 = α1 + α2 · · · · · · (4)
Solving (3) and (4), we get α1 = 4 and α2 = −3. (DO THE DETAILS YOURSELF)
Hence the solution {an } of this recurrence relation is of the form an = 4 − 3n.
2. Find the solution of the following recurrence relations:
a. an = −6an−1 − 9an−2 , a0 = 3, a1 = −3
5
b. an = 4an−1 − 4an−2 , a0 = , a1 = 8
2
Theorem 4 (Generalization of Theorem 3): (Statement only) Let c1 , c2 , · · · , ck be real num-
bers. Suppose that the characteristic equation rk − c1 rk−1 − · · · − ck = 0 has t distinct roots
r1 , r2 , · · · , rt with multiplicities m1 , m2 , · · · , mt respectively, so that mi ≥ 1 for i = 1, 2, · · · , t
and m1 + m2 + · · · + mt = k. Then a sequence {an } is a solution of the recurrence relation
an = c1 an−1 + c2 an−2 + · · · + ck an−k
if and only if

an = (α1,0 + α1,1 n + · · · + α1,m1 −1 nm1 −1 )r1n


+(α2,0 + α2,1 n + · · · + α2,m2 −1 nm2 −1 )r2n
+ · · · + (αt,0 + αt,1 n + · · · + αt,mt −1 nmt −1 )rtn
for n = 0, 1, 2, · · · where αi,j are constants for 1 ≤ i ≤ t and 0 ≤ j ≤ mi − 1.
Examples illustrating the use of Theorem 4:

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 24

1. Solve the recurrence relation an = 6an−1 − 12an−2 + 8an−3 with a0 = −5, a1 = 4 and
a2 = 88.
Solution: The given recurrence relation is

an = 6an−1 − 12an−2 + 8an−3 , a0 = −5, a1 = 4, a2 = 88 · · · · · · (1)

The characteristic equation of this recurrence relation is

r3 − 6r2 + 12r − 8 = 0

or, r3 − 3.2r2 + 3.22 r − 23 = 0


or, (r − 2)3 = 0
Therefore, the solution of the characteristic equation is r1 = 2 with multiplicity m1 = 3.
Hence the solution {an } of the recurrence relation must be of the form

an = (α1,0 + α1,1 n + α1,2 n2 )2n · · · · · · (2)

where α1,0 , α1,1 and α1,2 are constants.


When n = 0, then from equation (2), we get

a0 = (α1,0 + α1,1 .0 + α1,2 .02 )20

or, − 5 = α1,0 · · · · · · (3)


When n = 1, then from equation (2), we get

a1 = (α1,0 + α1,1 .1 + α1,2 .12 )21

or, 4 = 2α1,0 + 2α1,1 + 2α1,2


or, 2 = α1,0 + α1,1 + α1,2 · · · · · · (4)
When n = 2, then from equation (2), we get

a2 = (α1,0 + α1,1 .2 + α1,2 .22 )22

or, 88 = (α1,0 + 2α1,1 + 4α1,2 )4


or, 22 = α1,0 + 2α1,1 + 4α1,2 · · · · · · (5)
1 13
Solving equations (3), (4) and (5), we get α1,0 = −5, α1,1 =
, α1,2 = . (DO THE
2 2
DETAILS YOURSELF) Therefore, the solution {an } of the recurrence relation (1) is of
the form  
1 13 2 n
an = −5 + n + n 2 .
2 2
2. Find the solution of the following recurrence relations:

a. an = −3an−1 − 3an−2 − an−3 , a0 = 5, a1 = −9, a2 = 15

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 25

b. an = 7an−1 − 16an−2 + 12an−3 , a0 = 1, a1 = 4, a2 = 8


Hint: r3 − 7r2 + 16r − 12 = r3 − 7r2 + 12r + 4r − 12 = r(r2 − 7r + 12) + 4(r − 3) =
r(r − 3)(r − 4) + 4(r − 3) = (r − 3)(r − 2)2 = 0. Therefore r1 = 3, m1 = 1,
r2 = 2, m2 = 2. So an = α1,0 3n + (α2,0 + α2,1 n)2n .

Summary on solution of linear homogeneous recurrence relations:

1. Solving linear homogeneous recurrence relations of degree 2:


To solve a linear homogeneous recurrence relations of degree 2 of the form

an = c1 an−1 + c2 an−2 , a0 = d1 , a1 = d2

we follow the following four steps:

STEP I: Form the characteristic equation

r2 − c1 r − c2 = 0.

STEP II: Solve the characteristic equation to find the characteristic roots r1 and r2 .
STEP III: There are two cases that arises depending upon the nature of the roots r1 and r2 .
Case A: r1 6= r2
In this case, the solution of the recurrence relation is of the form

an = α1 r1n + α2 r2n

where α1 and α2 are constants.


Case B: r1 = r2
In this case, the solution of the recurrence relation is of the form

an = (α1 + α2 n)r1n

where α1 and α2 are constants.


STEP IV: Use the initial conditions, a0 = d1 and a1 = d2 to obtain the values of the constants
α1 and α2 .

2. Solving linear homogeneous recurrence relations of degree 3:


To solve a linear homogeneous recurrence relations of degree 3 of the form

an = c1 an−1 + c2 an−2 + c3 an−3 , a0 = d1 , a1 = d2 , a2 = d3

we follow the following four steps:

STEP I: Form the characteristic equation

r3 − c1 r2 − c2 r − c3 = 0.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 26

STEP II: Solve the characteristic equation to find the characteristic roots r1 , r2 and r3 .
STEP III: There are three cases that arises depending upon the nature of the roots r1 , r2 and
r3 .
Case A: r1 , r2 and r3 are all distinct:
In this case, the solution of the recurrence relation is of the form

an = α1 r1n + α2 r2n + α3 r3n

where α1 , α2 and α3 are constants.


Case B: r1 = r2 = r3
In this case, the solution of the recurrence relation is of the form

an = (α1 + α2 n + α3 n2 )r1n

where α1 , α2 and α3 are constants.


Case C: r1 = r2 and r3 is distinct:
In this case, the solution of the recurrence relation is of the form

an = (α1 + α2 n)r1n + α3 r3n

where α1 , α2 and α3 are constants.


STEP IV: Use the initial conditions, a0 = d1 , a1 = d2 and a2 = d3 to obtain the values of the
constants α1 , α2 and α3 .

5.2.3 Solving Nonhomogeneous Recurrence Relation


Linear nonhomogeneous recurrence relation: A linear nonhomogeneous recurrence relation
with constant coefficients is a recurrence relation of the form

an = c1 an−1 + c2 an−2 + · · · + ck an−k + F (n)

where c1 , c2 , · · · , ck are real numbers and F (n) is a function not identically zero depending
only on n.
For example, an = an−1 + 2an−2 + n2 + n is a linear nonhomogeneous recurrence relation.
Associated homogeneous recurrence relation: Given a linear nonhomogeneous recurrence
relation
an = c1 an−1 + c2 an−2 + · · · + ck an−k + F (n),
the recurrence relation
an = c1 an−1 + c2 an−2 + · · · + ck an−k
is called the associated homogeneous recurrence relation.
For example, an = an−1 +2an−2 is the associated homogeneous recurrence relation of the linear
nonhomogeneous recurrence relation an = an−1 + 2an−2 + n2 + n.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 27

(p)
Theorem 5: (Statement only) If {an } is a particular solution of the nonhomogeneous linear
recurrence relation with constant coefficients

an = c1 an−1 + c2 an−2 + · · · + ck an−k + F (n),


(p) (h) (h)
then every solution is of the form {an + an } where {an } is a solution of the associated
homogeneous recurrence relation an = c1 an−1 + c2 an−2 + · · · + ck an−k .
(p)
The particular solution an of a nonhomogeneous recurrence relation depends upon the function
F (n). We consider the cases when F (n) is either a polynomial function or an exponential
function or their product. The particular solutions in each of these cases is given below:
(p)
Finding particular solution an of a linear nonhomogeneous recurrence relation:

I: If F (n) = p(n) where p(n) is a polynomial of degree m, then the particular solution
(p)
an is a complete polynomial (i.e., containing all the terms) of degree m as well. For
(p)
example, if F (n) = n3 + 2, then F (n) is a polynomial of degree 3 and therefore an =
c1 n3 + c2 n2 + c3 n + c4 is the particular solution where c1 , c2 , c3 , c4 are some constants.
(p)
II: If F (n) = an is an exponential function of n, then the form of particular solution an
depends upon two cases as below:

Case A: If a is not a characteristic root of the associated homogeneous recurrence relation


(p)
then an = can where c is some constant.
Case B: If a is a characteristic root of the associated homogeneous recurrence relation which
(p)
is repeated s times, then an = cns an where c is some constant.

III: If F (n) = p(n)an where p(n) is a polynomial of degree m, then the form of particular
(p)
solution an again depends upon two cases as below:

Case A: If a is not a characteristic root of the associated homogeneous recurrence relation


(p)
then an = q(n)an where q(n) is a complete polynomial of degree m.
Case B: If a is a characteristic root of the associated homogeneous recurrence relation which
(p)
is repeated s times then an = q(n)ns an where q(n) is a complete polynomial of
degree m.

Examples:

1. Find all solutions of the recurrence relation

an = −5an−1 − 6an−2 + 3n2 · · · · · · (1)

Solution: The associated homogeneous recurrence relation of the given recurrence rela-
tion is
an = −5an−1 − 6an−2 · · · · · · (2)

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 28

The characteristic equation of this recurrence relation is r2 + 5r + 6 = 0 whose solutions


(h)
are r1 = −2 and r2 = −3. So the solution {an } of the recurrence relation (2) is of the
form
an(h) = α1 (−2)n + α2 (−3)n
or, a(h) n n n
n = (−1) (α1 2 + α2 3 )
(p)
Since F (n) = 3n2 is a polynomial of degree 2, assume that an = c1 n2 + c2 n + c3 is one
particular solution of (1). Then from (1)
c1 n2 + c2 n + c3 = −5[c1 (n − 1)2 + c2 (n − 1) + c3 ] − 6[c1 (n − 2)2 + c2 (n − 2) + c3 ] + 3n2
or, 12c1 n2 − (34c1 − 12c2 )n + (29c1 − 17c2 + 12c3 ) = 3n2
Comparing the LHS and RHS, we get
12c1 = 3, −(34c1 − 12c2 ) = 0, 29c1 − 17c2 + 12c3 = 0.
1 17 115
Solving the above equations, we get c1 = , c2 = , c3 = . (DO THE DETAILS
4 24 288
(p)
YOURSELF) So the particular solution {an } of (1) is of the form
1 2 17 115
a(p)
n = n + n+ .
4 24 288
Hence all the solutions of (1) are of the form
1 2 17 115
an = a(h) (p) n n n
n + an = (−1) (α1 2 + α2 3 ) + n + n+ .
4 24 288
2. Find all solutions of the recurrence relation
an = −5an−1 − 6an−2 + 7n · · · · · · (1)

Solution: The associated homogeneous recurrence relation of the given recurrence rela-
(h) (h)
tion is an = −5an−1 − 6an−2 whose solution {an } is of the form an = (−1)n (α1 2n +
α2 3n ).
Since F (n) = 7n and 7 is not a characteristic root of the associated homogeneous recur-
(p)
rence relation, we let an = c7n be the particular solution of (1) where c is some constant.
Then from (1), we get
c7n = −5c.7n−1 − 6c.7n−2 + 7n
or, c72 = −5c.7 − 6c + 72
or, 49c = −35c − 6c + 49
or, 49c + 41c = 49
49
or, c =
90
(p) 49 n 7n+2
So an = 7 = is a particular solution of (1). Hence all solutions of (1) are of
90 90
the form
7n+2
an = (−1)n (α1 2n + α2 3n ) + .
90

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 29

5.2.4 Divide-and-Conquer Algorithms and Recurrence Relations


Divide-and-conquer is a strategy of problem solving where one first divides the given problem
into one or more instances of similar subproblems but with smaller input size than the original
problem. This division is continued until the stage is reached when one can easily solve the in-
dividual subproblems. Then the process of “conquering” starts where these solved subproblems
are somehow combined to form the solution of the original problem. The algorithms that use
the divide-and-conquer strategy to solve problems are called divide-and-conquer algorithms.
Binary search algorithm used to locate an element in a given list of n elements is an example
of divide-and-conquer algorithm. Similarly the merge sort algorithm used to sort a given list
of n elements into ascending or descending order is also an example of divide-and-conquer
algorithm.
The computational complexity (i.e. the number of operations required to solve a problem of size
n) of most of the divide-and-conquer algorithms can be estimated using a recurrence relation. If
an algorithm divides a problem of size n into a similar subproblems each of size n/b and g(n)
denotes the number of extra operations required to combine the solution of subproblems in the
“conquer” phase of the algorithm then the number of operations required to solve this problem,
denoted by f (n), can be represented by a recurrence relation as
n
f (n) = af + g(n).
b
This recurrence relation is called a divide-and-conquer recurrence relation. Solving this recur-
rence relation will help us to estimate the number of operations to solve the given problem.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 30

5.3 Exercise

5.3.1 Basics of Counting


1. How many different bit strings of length 9 are there that begins with a 1 and ends in 00?
2. How many different bit strings are there of length n that starts and ends in 1?
3. How many bit strings of length 11 are there that starts and ends in 01?
4. How many ways are there to select first, second and third prize winners from 10 different
students?
5. Determine the number of ways that a football team can be formed from a pool of 40
players.
6. Find the number of different license plates if it contains a sequence of three letters fol-
lowed by three digits.

5.3.2 Pigeonhole Principle


1. How many numbers must be selected from the numbers 1 to 10 to guarantee that the sum
of at least one pair of selected numbers is 11?
2. In a group of 100 people, find the minimum number of people who were born in the same
month.
3. Find the minimum number of students in a class to be sure that five of them are born in
the same month.
4. Find the minimum number of people in a room for 6 of them to be born in the same
weekday.
5. Use pigeonhole principle to find the minimum number of students in a class to guarantee
that at least two students receive the same score on the exams if the exam is graded from
0 to 60.
6. Find the minimum number of students to guarantee that 50 of them obtain same grade
where there are altogether 20 different grades.
7. How many cards must be selected from a deck of 52 cards to ensure that at least 3 cards
of the same suite are chosen?

5.3.3 Permutation and Combination


1. Find the values of P (10, 4) and P (10, 6).
2. How many permutations of the letters B, C, D, E, F, G, H, I contain the string CGI?
3. How many 4-letter words are possible from the vowel letters?
4. In how many ways can the letters of the word MISSISSIPPI be arranged?

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 31

5. In how many ways can the letters of the word COCACOLA be arranged?
6. In how many ways can numbers on the clock face be arranged?
7. Find the number of ways in which a group of eight people can arrange themselves around
a circular table if two of them must sit together.
8. A competition distributes prizes to the top 5 players among 15 players. If two of the
players are guaranteed to be among the top five, then find the number of ways in which
the prize can be distributed among 15 players. What if two players are definitely not
going to be among the top five?
9. Compute the values of C(10, 4) and C(10, 6) using the formula.
10. Calculate C(15, 4). Hence find the value of C(15, 11) without using any calculation.
11. How many subsets of 5 elements can be made from a set with 11 distinct elements?
12. Determine the number of ways that a football team can be formed from a pool of 40
players.
13. If n is an even integer, how many bit strings are there of length n with equal number of
0’s and 1’s?
14. In how many ways can a committee consisting of three men and three women be formed
from seven men and five women?
15. In how many ways can 5 balls be chosen from an urn containing 8 red and 7 black balls
so that (i) they must all be of same color? (ii) three are red and two are black?
16. Prove that kC(n, k) = nC(n − 1, k − 1).
17. In how many ways can 5 balls be selected from a box containing red, green and blue balls
if the order in which the balls are selected does not matter and there are at least 5 balls of
each color?

5.3.4 Binomial Coefficients


5
a2

2
1. Find the general term in the expansion of x + .
x
 10
th 1
2. Find the 7 term of x + .
x
 7
th 2
3. Find the 5 term of x − .
x
 7
5 1
4. Find the coefficient of x in the expansion of x + .
2x
5. Find the coefficient of x2 y 4 in the expansion of (x + y)6 .
6. What is the coefficient of x3 y 4 in the expansion of (x + 3y)7 ?
7. What is the coefficient of x12 y 13 in the expansion of (2x − 3y)25 ?

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 32

8. Find the general term and the middle terms in the expansion of (2a + 3b)12 .
 9
1
9. Find the middle term(s) in the expansion of 2x + 2 .
3x
15
a2
 
10. Find the middle terms of 2x2 − .
x
 12
2 1
11. Find the term independent of x in the expansion of x + .
x
 9
1
12. Find the term independent of x in the expansion of 2x + 2 .
3x
 2 9
3x 1
13. Find the term independent of x in the expansion of − .
2 3x
n  
X n
14. Use the binomial theorem to prove 2k = 3n .
k
k=0
6
15. Find the expansion of (1 + 2x) using Pascal’s triangle.
16. Find the expansion of (2x − 3)5 using Pascal’s triangle.

5.3.5 Discrete Probability

5.3.6 Advanced Counting


1. What is the form of the solution of a linear homogeneous recurrence relation if its char-
acteristic roots are 2, 2, 3, 3, 3, −1?
2. What is the form of the solution of a linear homogeneous recurrence relation if its char-
acteristic roots are 5, 5, 5, −2, −2, 1, 1, 1, 4?
3. Determine whether the sequence an = 2n is a solution of the recurrence relation an =
−3an−1 + 4an−2 or not.
4. Determine whether an = −n + 2 is a solution of the recurrence relation an = an−1 +
2an−2 + 2n − 9.
5. Determine whether an = −6n + 2 is a solution of the recurrence relation an = an−1 +
2an−2 + 2n − 9.
6. Determine whether an = 2n is a solution of the recurrence relation an = 8an−1 − 16an−2 .
7. Let an = an−1 − an−2 for n ≥ 2 with a0 = 3 and a1 = 5. Find the values of a2 and a3 .
8. Solve the recurrence relations using the iterative approach:
an−1
(a) an = with a1 = 1.
n
(b) an = 2an−1 , a0 = 1.
(c) an = 2an−1 − 3, a0 = −1.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 33

(d) an = nan−1 , a0 = 5.
(e) an = an−1 + 2, a0 = 3
(f) an = an−1 + 3n , a0 = 1.
(g) an = an−1 + n2 , a0 = 7
(h) an = ran−1 + s where r and s are constants.
111
(i) Pn = Pn−1 , P0 = 10, 000
100
(j) Hn = 2Hn−1 + 1, H1 = 1

9. Solve the following recurrence relations:

(a) an = an−1 + 6an−2 , with the initial conditions a0 = 3, a1 = 6.


(b) an = −6an−1 − 9an−2 with the initial conditions a0 = 3 and a1 = −3.
(c) an = 6an−1 − 9an−2 with the initial conditions a0 = 3 and a1 = −3.
(d) an = 7an−1 − 10an−2 with initial conditions a0 = 2 and a1 = 1.
(e) an = an−1 + 2an−2 with initial conditions a0 = 2 and a1 = 7.
(f) an = 8an−1 − 16an−2 with initial conditions, a0 = 5 and a1 = 8.
(g) an = an−1 + an−2 with initial conditions a1 = 2 and a2 = 3.
(h) an = 3an−1 + 4an−2 with initial conditions a0 = a1 = 1.
(i) an = 6an−1 − 8an−2 with initial conditions a0 = 4, a1 = 10.
(j) an = 4an−2 , with initial conditions a0 = 0, a1 = 4.
(k) an = 4an−1 − 4an−2 , with the initial conditions a0 = 6, a1 = 8.
(l) an = −4an−1 − 4an−2 , with the initial conditions a0 = 0, a1 = 4.
(m) an = 6an−1 − 9an−2 , with initial conditions a0 = 1, a1 = 6.
5
(n) an = −4an−1 − 4an−2 , with the initial conditions a0 = , a1 = 8.
2
an−2
(o) an = with initial conditions a0 = 2, a1 = 8.
4
(p) an = an−2 , with initial conditions a0 = 5, a1 = −1.
(q) an = −4an−1 + 5an−2 , with initial conditions a0 = 2, a1 = 8.
2
10. For the Fibonacci sequence {fn }, prove that fn+1 − fn2 = fn−1 fn+2 for n ≥ 2.
11. Find an explicit formula for the sequence 2, 5, 7, 12, 19, 31, · · · .
12. Solve the following recurrence relations:

(a) an = 6an−1 − 11an−1 + 6an−3 with the initial conditions a0 = 2, a1 = 5, a2 = 15.


(b) an = 7an−2 + 6an−3 with the initial conditions a0 = 9, a1 = 10, a2 = 32.
(c) an = 5an−2 − 4an−4 with initial conditions a0 = 3, a1 = 2, a2 = 6, a3 = 8.
(d) an = 7an−1 − 16an−2 + 12an−3 with the initial conditions a0 = 1, a1 = 4, a2 = 8.

P RAJWAL K ANSAKAR - for CSIT @Prime


UNIT 5. COUNTING AND DISCRETE PROBABILITY 34

(e) an = −3an−1 − 3an−2 − an−3 with initial conditions a0 = 5, a1 = −9 and a2 = 15.


(f) an = 2an−1 + 5an−2 − 6an−3 with initial conditions a0 = 7, a1 = −4, a2 = 8.
(g) an = 2an−1 + an−2 − 2an−3 with initial conditions a0 = 3, a1 = 6, a2 = 0.
(h) an = 8an−1 − 21an−2 + 18an−3 .
(i) an = an−2 − 16an−4 .
(j) an = 6an−1 − 12an−2 + 8an−3 + 3n .
(k) an = 6an−1 − 12an−2 + 8an−3 + 2n .
(l) an = 6an−1 − 12an−2 + 8an−3 + n2 .
(m) an = 2an−1 + 4n .
(n) an = 2an−1 + n2 + n.
(o) an = 8an−1 − 16an−2 + n2 .
(p) an = 7an−1 − 10an−2 + 4n .
(q) an = −5an−1 − 6an−2 + 5n .
(r) an = 5an−1 − 6an−2 + 7n + 2.
(s) an = 5an−1 − 6an−2 + n2 − n.
(t) an = 4an−1 − 4an−2 + (n + 1)2n .

P RAJWAL K ANSAKAR - for CSIT @Prime

You might also like