Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

4 Counting

Sum and Product Rule can be performed simultaneously), then the


number of ways to do one of these tasks is
Rule of sum: W1 + W2 + … + Wn
If there are m choice for one event and n
choices for another event, both can not
Note:
occur at the same time, then their m + n
In the rule of addition, jobs are performed
choices for one event.
independently. In this case, we use the word
If a sequence of tasks T1, T2 … Tn can be done ‘or’ between various jobs, and the meaning
in W1, W2 …, Wn ways respectively (no tasks of ‘or’ is addition.

Solved Examples
1. In how many ways can we draw a face Rule of product:
card from a deck?
If there are m choices for one event and n
Solution: choices for another event, then there are m
In a deck of 52 cards, there are 4 suits. × n choices for both these events to occur.
If a sequence of tasks T1, T2 … Tn can be done
in W1, W2, …, Wn ways respectively (every task
arrives after the occurrence of the previous
J→4 task) then the number of ways to perform all
the tasks is W1 × W2 × … × Wn.
Q→4

K→4 Note:
In the rule of multiplication, different jobs/
We want to draw a one-face card between
operations are mutually inclusive, it implies
all these no of choice = 4 + 4 + 4 = 12
that all jobs are being done in succession.
In this case, we use word ‘and’ to complete
2. A pencil box contains 2 red and 3 black
all stages of operation, and the meaning of
pens. Total number of ways for selecting
‘and’ is multiplication.
1 red pen and 1 black pen or 2 red pens.
Solution:
2 ways for selecting red pens because 2 pens 3. Let us consider the following. Rahul has
are there. 3 pants and 2 shirts. How many different
pairs of pants and a shirt, can he dress
3 ways for selecting black pens because 3
up with?
pens are there.
Solution:
∴ Total ways for selecting 1 red and 1 black
=3×2=6 There are 3 ways in which a pant can be
chosen (because 3, pants available) says P1,
∴ Number of ways of selecting 2 red pens = 1
P2, P3
Total ways for selecting 1 red and 2 black or
2 red is 6 + 1, i.e., 7 ways.

Counting 85
Similarly, a shirt can be chosen in 2 ways. Solution:
(Because 2 shirts available, say S1, S2). A die can fall in 6 different ways, i.e., 1, 2, 3,
For every choice of a pant, there are 2 choices 4, 5, 6, and a coin can fall in 2 different ways,
of a shirt. i.e., head or tail.
Therefore, there are 3 × 2 = 6 pairs of pants Number of possible outcomes from a die
and shirts. and a coin = 6 × 2 = 12 ways.

S1 P1S1 6. There are 7 trains running between Delhi


P1 and Lucknow. In how many ways can
S2 P1S2
S1 a man go from Delhi to Lucknow and
P2 P2S1
S2
return by a different train?
P2S2
S1 P3S1 Solution:
P3
S2 P3S2 A man can go from Delhi to Lucknow in 7
ways (by anyone the 7 trains available).
4. Find the number of 4 letter words with He can return from Lucknow to Delhi in 6
or without meaning possible, using the ways by the remaining 6 trains (since, he
given set of 4 letters, here repetition of cannot return by the same train by which he
letters is not allowed. goes from to Lucknow to Delhi).
Solution: Required number of ways = 7 × 6
There are as many words as there are the = 42
way of filling in 4 vacant places by the 4
letters (repetition is not allowed). 7. How many 3 digit numbers can be
formed, whose unit digit is always zero
and repetition of the digit is not allowed?
4 3 2 1
Solution:
First place can be filled in 4 different ways
by any one of the four letters. Second place Hundreds Tens Unit
can be filled by anyone of the remaining 3
letters in 3 different ways, following third
place can be 2 different ways.
Following 4 places can be filled in one way.
9 8 1
Thus, the no of ways in which the 4 places
can be filled by the multiplication principle Since, zero is fixed for the unit digit place. So,
is 4 × 3 × 2 × 1 = 24 only 9 digits are available for the hundreds
place, and only 8 digits are available for the
Note: tens place out of 10 digits, i.e., 0, 1, 2, 3, ..., 9.
If the repetition of the letters was allowed Therefore, required possible numbers = 9 ×
in the above problem, one could easily 8 × 1 = 72
understand that each of 4 vacant places
can be filled in succession in 4 different Factorial:
ways. Hence the required number of words Factorial of ‘n’ gives the product of all number
= 4 × 4 × 4 × 4 = 256 the numbers between 1 to n.

5. If a die is cast and then a coin is tossed, n! = n(n − 1)(n − 2)...3.2.1


find the number of all possible outcomes

86 Counting
y Permutation of n different thing taken r at
a time when a particular thing always
Rack Your Brain occurs = r*(n−1)P(r − 1)

y Permutation of n different things taken r


A GATE test paper consists of 65 questions at a time when a particular thing never
and each question has 5 choices. If each occurs = (n – 1)Pr
question is necessarily attempted, then
find the number of ways of answering the Permutation of n things not all different:
GATE test paper. y Number of permutations of n things, taken
all at a time, of which p are alike of one kind,
Permutation: q and alike of the second kind, r is alike of
y The words permutation comes from the n!
the third kind and rest are different =
Latin words per + mutare that together p ! q!r !
mean “by change” or “through change”. y Number of permutations of n things of
y An arrangement of a set of an object is which P1 are alike of one kind, P2 are alike
called a permutation. of second kind, P3 are alike of third kind …
y In permutation orders matter. Pr are alike of rth kind such that
y Factorial plays an important part in n!
determining the total permutation of a P1 + P2 + P3 ... + Pr =
n is P !P !P ! ... P !
1 2 3 r
given set without repetitions.
n! = n(n − 1)(n − 2)...3.2.1 8. How many 4-digit even numbers are
there (repetition is allowed)?
n! represents the number of permutations
of n different objects. Solution:

y The number of permutation, ↓ ↓ ↓ ↓


9 10 10 5
(arrangements) of n different things taking
r at a time is considered as a partial First place, one can fill in 9 ways (1 to 9)
permutation. It is written as n any value (Because zero cannot come at first
P r
position)
(“n permute r”)
n! Second place, one can fill in 10 ways (0 to 9)
n
Pr = p(n,r) = any value
(n − r) !
y Number of ways of arranging ‘n’ things in Third place, one can fill in 10 ways (0 to 9)
which q things are identical of one type any value
and p things are identical of another type Fourth place, one can fill in 5 ways (0, 2, 4,
n! 6, 8) any value
=
p ! q!
Using product rule = 9 × 10 × 10 × 5 = 4500
y Total permutations of n distinct things
round a close curve = (n-1)! (if clock wise
and anticlockwise arrangements are Previous Years’ Questions
considered different)
1 How many 4 digit even numbers have all
= (n − 1) ! (If clock wise and anticlockwise
2 4 digits distinct?
arrangement are considered identical) (A) 2240 (B) 2296
y Permutation of n different things taken all (C) 2620 (D) 4536
at a time = n p n = n! Solution: (B) [GATE 2001]

Counting 87
Combination: y)n nC 0 xn−0 y 0 + nC 1xn−1 y 1 + ...nC nxn−n yn
y (x +=
y An unordered selection of object is called
a combination. y 2n = nC + nC + nC ... + nC
0 1 2 n
y In combination arrangement of things
{Put x = 1 and y = 1 in above equation}
doesn’t matter until the specific thing is
to be included. y (1 + x)n = nC + nC x + nC x2 + ...nC xn
0 1 2 n
y The combination of three alphabets {a, b,
c} taken two at a time are {a, b}, {a, c}, {b, y n ⋅ 2n− 1 = 1 ⋅ nC + 2 ⋅ nC + ... + n ⋅ nC
1 2 n
c}, here {a, b} and {b, a} are not considered
separately. {By differentiate above and put x = 1}
y The word combination and selection are
2n
synonymous. y nC + nC + nC +  = nC + nC + nC +  = = 2n− 1
0 2 4 1 3 5 2

2n
nC + nC + nC +  = nC + nC + nC +  = = 2n− 1
Rack Your Brain 0 2 4 1 3 5 2

Combination with repetition:


How many ways 65 True/False question
can be answered if you can skip any of y The number of combinations of n objects
the question? taken r at a time with repetition.
(A) 65 P3 (B) 65 C3 y The number of ways r identical objects can
be distributed among n distinct boxes.
(C) 365 (D) 653
y The number of non-negative Integral
solution of the equation x1 + x2 + x3 +…+xn
y The number of combinations of n distinct
= r where x1 ≥ 0, x2 ≥ 0 … xn ≥ 0
objects taken r at a time without repetition
y The solution of all the above statement is
denoted by n Cr (read as n choose r).
(n− 1+r)
Cr
n n(n − 1)(n − 2)...(n − (r − 1)
Cn = Properties of nCr for simplification:
r(r − 1)(r − 2)...2.1
n n
n!
y = C0 1,=Cn 1
n
y C(n,r)
= Cr
=
r !(n − r) ! y n
Cr = nCn−r
n
n
n
Pr n! n! y Cr + nCr − 1 =
n+ 1
Cr
y Cr
= = =
r! (n − r) ! (n − r) !r ! n n
y= Cr Ck ⇒=r k or r +k n
=
r!
y r ⋅ nCr =n ⋅ n− 1Cr − 1
y Selecting r objects out of n is the same as
selecting (n-r) object out of n 1 n 1 n+ 1
y ⋅ Cr = ⋅ Cr + 1
{k-selection equal to k rejection} r+1 n+ 1
y Total selections that can be made from ‘n’ 9. In how many ways can you distribute 10
n
similar balls into 3 distinct boxes.
distinct items are given ∑ n
Ck = 2n
12
k =0 (A) C10
n n− 1 n− 1
Cr
y = Cr + Cr − 1 (B) 13
C10
y Total ways of selecting one or more objects (C) 12
C2
from n distinct objects 13
(D) C3
n n n n n
=2 − 1 =( C1 + C2 + C3 + ... + Cn )

88 Counting
Solution: (A), (C)

x1 x2 x3 Rack Your Brain

Let x1 x2 x3 are number of balls in box 1, box In how many ways of placing 20 similar
2, box 3 respectively. balls into 4 boxes where each box is non
So, x1 + x2 + x3 = 10 [n = 3, r = 10] empty?
Using n – 1 + r Cr = 3–1 + 10
C10 = 12
C10 = 12
C2

Solved Examples

10. In how many ways you can place atmost y The number of ways of dividing 2p items
7 similar balls into 4 distinct boxes. (2p) !
into two equal groups of p each is ,
Solution: 2 !(p !)2
Let x1,x2,x3,x4 are the number of balls in box 1, where the two groups do not have a distinct
2, 3, 4 respectively. identities.
y The number of ways in which (p + q + r)
x1 x2 x3 x4
things can be divided into three groups
So, x1 + x2 + x3 + x4 ≤ 7. ∀xi ≥ 0 here r containing p, q, and r things, respectively,
value can be any of between 0 to 7. (p + q + r) !
is
7
p ! q!r !
=
So, ∑n − 1 + r
r =0
Cr
{n = 4} Difference between permutation and
combination:
7
Permutation Combination
= ∑3 +r Cr
r =0 Order is not
Order is important
3 4 5 6
= C0 + C1 + C2 + C3 + C4 + C5 + C6 + C7 7 8 9 10 important
= 1 + 4 + 10 + 20 + 35 + 56 + 84 + 120 Arrangement Selection
= 330 Keywords: Sets,
Keywords: password,
subset, team,
number, word
committee
Note:
The above problem can also solve using Derangement:
taken n = 5 (one more box as dustbin) and r y Derangement is a permutational
is 7 in formula n−1+r Cr. arrangement with no fixed points.
y Arrangement of elements in such a way
Dividing given into groups: that no is in its correct position. If n
y The number of ways of dividing (p + q) distinct items are arranged, the number
items, into two groups of p and q items, of ways they can be arranged so that they
do not occupy their intended spot is:
(p + q) !
respectively is
p ! q!  1 1 1 1 ( −1)n 
D
=n
n!  − + − +  
y The number of ways of dividing 2p items  0 ! 1! 2 ! 3 ! n! 
(2p) !
into two equal groups of p each is n
n!
(p !)2 Dn
= ∑ (−1) r
r!
where two groups have distinct identities. r =2

Counting 89
Solved Examples

11. There are 5 tables in a class, each Derangement of the remaining 5 envelopes
table containing the roll number of the and letters D5 = 44
student. How many ways can 5 students
Total number of ways of arrangement = 44 ×
be arranged such that no student sits at
21 = 924
the table having their own roll number?
Solution:
Previous Years’ Questions
This is a clear case of derangements of 5
tables and 5 students
In how many ways can we distribute 5
 1 1 1 1 1  distinct balls, B1, B2, …, B5 in 5 distinct
D5= 5 !  1 − + − + − 
 1! 2 ! 3 ! 4 ! 5 !  cells, C1, C2, …, C5 such that Ball B is not
in cell Ci, ∀ = 1, 2, … 5, and each cell
 1 1 1 1  i
= 120  1 − 1 + − + −  contains exactly one ball?
 2 6 24 120 
(A) 44 (B) 96
 60 − 20 + 5 − 1  (C) 120 (D) 3125
= 120 ×  
 120  Solution: (A) [GATE 2004]
= 44
Number of divisors:
12. In how many ways can you put 7 letters If the prime factorisation of n is P1e1 ⋅ P2e1  Pkek ,
into their respective envelopes such that where P1 are distinct prime numbers then
exactly 2 go into the right envelope? the Number of divisors is
Solution: d(n) = (e1 + 1) × (e2 + 1) … × (ek + 1)
Number of ways in which the 2 correct Sum of the divisor is
envelopes can be selected
e1 + 1 e2 + 1 ek + 1
P1 −1 P2 −1 Pk −1
7 × 6 × 5! σ
=(n) × ×
= 7=
C2 7=
C5 = 21 P1 − 1 P2 − 1 Pk − 1
5! 2!

Solved Examples y (1 + x)n = nC0 + nC1 x + nC2 x2 + … + nCn xn.


y (1 + x)n = (x + 1)n = nC0 xn + nC1 xn-1 + nC2 xn-2
13. How many divisors of 1500?
+…+nCn
Solution: When expanded in descending powers of x.
1500 = 22 × 31 × 53 y (a – x)n = nC0 an – nC1 an-1 x + nC2 an-2 x2 - …
Number of divisors d(n) = (2 + 1) × (1 + 1) × +(-1)n ⋅ nCnxn.
(3 + 1)
=3×2×4
Previous Years’ Questions
= 24
Binomial theorem: The number of divisors of 2100 is ______.
(A) 42 (B) 36
y (a + x)n = nC0 an + nC1 an–1 x + nC2 an-2 x2 + …
(C) 78 (D) 72
n! Solution: (B) [GATE 2015]
+ nCnxn Where n Cr = .
r !(n − r) !

90 Counting
Properties of binomial coefficient: Multinomial theorem:
n
� Cr = nCn-r (symmetry) The multinomial theorem describes how to
n n-1 n-1 expand the power of a sum in terms of the
� Cr = Cr + Cr-1 (Pascal identity)
power of the terms in that sum. It is the
n r n n-k
� Cr × Ck = Ck × Cr − k (Newton’s identity) generalisation of the binomial theorem from
n binomials to multinomials.
�  ∑
r=0
n
Cr = nC0 + nC1 + nC2 +  nCn = 2n

n  t n
(Row summation) (x 1 + x2 +  xt )n
= ∑  ∏
⋅ xm
n ,n  nt  m = 1 m
n 1 2
∀n1 + n2 + nt =
n
� ∑ (-1) r r
Cr = nC0 – nC1 + nC2 – nC3  = 0 n  n!
r =0 where   =
 n1 ,n2  nt  n1 !n2 !  nt !
(Alternating sign row summation)
r
� Cr + r + 1Cr + 1 + r +2Cr +2 +  + nCr =
n+ 1
Cr + 1
(Column summation) Note:
r The coefficient of x 1n1 x2n2  xtnt in the
� ∑
K =0
n m n m n
CK ⋅ Cr −K = C0 ⋅ Cr + C1 ⋅ Cr −1 + C2 ⋅ Cr −2 m n m n
Cr ⋅ mC0 = nof
+ expansion +m
C(xr + x + … x )n
1 2 t
n!
where n = n1 + n2 + … nt is .
= nC0 ⋅ mCr + nC1 ⋅ mCr −1 + nC2 ⋅ mCr −2 +  nCr ⋅ mC0 = n+m
Cr n1 !n2 !  nt !

(Vandemondes identity)

Solved Examples Catalan numbers:


The nth Catalan number is given directly in
14. The coefficient of a4b5 in the expansion terms of binomial coefficients by
of (a + b)9 is ______.
Solution: n
2n
Cn 1  2n  2n! n+K
Coefficient of a4b5 is = =   =
n + 1 n + 1  n  (n + 1) !n! ∏
K =2
K
∀n≥0
9! 9 × 8 × 7 × 6 × 5!
= = = 126
4!5! 4 × 3 × 2 × 5! The first Catalan number for n = 0, 1, 2, 3,
15. The coefficient of a4b5 in the expansion … are 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862,
of (2a – 3b)9 is_____.
16796, 58786, 208012, 742900 …
Solution:
Coefficient of a4b5 is
Note:
9! The total number of the path without
= (2)4 ⋅ ( −3)5
4!5! crossing the diagonal from (0, 0) to (n, n) is:
= 126 × 16 × (–243)
 2n   2n 
= –489,888 Cn   − 
=
 n   n + 1 
   

1
Rack Your Brain Cn = 2n
n + 1 Cn

The coefficient of a3 b2 g1 d4 in the expansion


of (a + 3b + 2g – 7d)10 is_____.

Counting 91
Solved Examples � Polygon triangulation (A convex polygon
with n + 2 sides can be triangulated in Cn
16. In how many ways can we start from (0, ways.
0) and go to (5, 5) without crossing the � If 2n people are seated around a circular
diagonal? (Assuming that you can move table, the number of ways can all of them be
up or right). simultaneously shaking hands with another
person at the table in such a way that none
Solution: of the arms crosses each other is Cn.
� Number of full binary trees with n + 1
1 2n
Cn = Cn leaves is Cn.
n+1
Generating function:
1 A generating function is a way of encoding an
= 2 × 5C
5+1 5
infinite sequence of numbers (an) by treating
them as the coefficients of a formal power
1
= 10 series. This series is called the generating
6 C5
function of the sequence.
10 ! Consider a sequence (a0,a1,a2…an…) of real
=
6 ⋅ 5!5! numbers then a function f(x) is defined as f(x)
= 42 = a0+a1x+a2x2+…anxn+… is called generating
function of the sequence.
Application of catalan numbers:

There are number of applications which can f(x) = ∑a x
r =0
r
r

be solved using Catalan numbers.


� Balanced parenthesis (form a valid group
of parenthesis).

Solved Examples
17. Find generating function for finite 19. Find the generating function for 1, 2, 3, 4
sequence: Solution:
a0, a1, a2, a3, a4
f(x) =1 + 2x + 3x2 + 4x3 + ...
Solution:
We know that,
f(x) =a 0 + a 1x + a 2 x 2 + a 3 x 3 + a 4 x 4
1
=1 + x + x2 + x3 + x4 ...
1− x
18. Find generating function for the infinite
sequence: d
Differentiate both side by
1, 1, 1, 1… dx
Solution:
Generating function of 1, 1, 1, …
d  1 
 =
d
dx  1 − x  dx
(
1 + x + x2 + x2 + x4 + ... )
1
= 1 + x + x 2 + x3 + x4 + … ∞ = (sum of
1− x
a 1
infinite GP series ) =1 + 2x + 3x2 + 4x3 + ...
1− x (1 − x)2

92 Counting
Solution:
To simplify the expansion. We extract x2
Rack Your Brain coefficient of x12 in
⇒ coefficient of x12 in (x2)2 (1+x+x2+…)2
Generating function for 12 , 22 , 32 , 42...
2
 1 
4
coefficient of x in x 
12

Identities of generating functions: 1− x
 2 3 1 
1 + x + x + x + ... = 
n
1. (1 + x)n =
1 + nC1 x + nC2 x2 + ... nCn xn = ∑
r =0
n
Cr xr  1 − x

1
1 1−1 −xnxn coefficient of x8 in the expansion of
2.1 +1 +x x+ +x2x......
2
+ +xnx−n1 −=
...... = (1 − x)2
1 −1 −x x

1 ∞ coefficient of x8 in ∑ (r + 1) x r
(put r = 8)
3. 1 + x + x + x =
2
...
r =0
x
=
1− x
3
∑ r
r =0

so coefficient of x12 in the (x2 + x3 + x4 +…)2 is


n n 8+1=9
1  1   ∞ r ∞
4. = 
(1 − x)n  1 − =
=

x


x
 r 0=
=


 r 0

n − 1 + r Cr xr ∑
∞ ∞ Previous Years’ Questions
1
5.
(1 −
=
x)2
=r 0=r 0
(r + 1)
∑C
=r
xr
(r + 1)xr ∑

1

Let
= G(x) =
(1 − x)2
∑ g(i)x , where |x| < 1
i

1 (r + 1)(r + 2) r i =0
6.
(1 − x) 3
= ∑ r =0
2
x
what is g(i).
(A) i (B) i + 1
1 ∞ (C) 2i (D) 2i
7. =
1+ x ∑ (−1) x
r =0
r r
Solution: (A) [GATE 2005]


1
8.
1 − ax
= ∑a x
r =0
r r

∞ ∞ ∞
Rack Your Brain
x
9.
= (1 − x)2
= (r + 1)

r 0=r 0=
Cr∑xr+1
= (r + 1)xr+1
= ∑
K 1
KxK ∑ Find coefficient of x12 in the expansion of
∞ ∞ ∞ (x3 + x4 + x5 + …)2 is _______.
x
x)2
= ∑ (r + 1)

r 0=r 0=
Cr xr+1
=∑ (r + 1)xr+1
=
K 1

KxK (if r+1 = k)

The pigeonhole principle:


x2 ∞
10. =
(1 − x)2
∑K ⋅ x
K =0
K+1
Principle 1:

If k is a positive integer and k+1 or more objects


20. Find coefficient of x in the expansion of 12 are placed into k boxes, then there is atleast
(x2 + x3 + x4 + …)2 one box containing two or more of the objects.

Counting 93
Previous Years’ Questions Previous Years’ Questions

If the ordinary generating function of a Which one of the following is a closed


1+z form expression for the generating
sequence {an }

is , then a3 – a0 function of the sequence {an}, where an
n= 0
(1 − z)3
is equal to _______. = 2n + 3 for all n = 0, 1, 2…?
Solution: 15 [GATE 2017] 3 3x
(A) (B)
2
(1 − x) (1 − x)2
2−x 3−x
Proof: (C) (D)
(1 − x)2 (1 − x)2
We use proof by contraposition. Suppose none
of the boxes has more than one object. Then Solution: (D) [GATE 2018]
the total number of objects would be atmost K.
This contradicts statements that we have Proofs:
K+1 objects. Use the pigeonhole principle
Generalised pigeonhole principle: � Create a box for each element Y in the co-
If N objects are placed into k boxes. Then, domain of f.
there is atleast one box containing N  y Put in the box for Y all of the elements x
 K the domain such that f(x) = Y.
objects.
y Because there are K+1 elements and only
Theorem: K boxes, atleast one box has 2 or more
A function f from a set with K+1 elements to elements.
a set with K elements is not one-to-one. Hence, f can not be one-to-one.

Solved Examples Application of pigeonhole principle:


y Number theory
21. Owner of a house boys ‘3’ distinct y Economics
colours wall paints. He wants that in y Probability
his house atleast 10 walls should be the y Finance
same colour. For his desire to be full y Algorithms
filled minimum, how many walls should y Computer science
be there in his house? y Mathematical analysis
Solution: y Computer programming
y Arithmetic
By using pigeon-hole principle:
y Geometry
én  1 ù ì n  no. of walls ü
10 ³  1 í ý
ê ú î þ
ë m û m  no. of distinct colours
Rack Your Brain
én  1 ù
10 ³  1
ê ú If 100 cars are painted with 7 colours.
ë 3 û
Atleast how many cars painted with
N ≥ 28
same colour?
∴ Atleast 28 walls should be there for
the desire of the landloard to be fulfilled.

94 Counting
Recurrence relation: The recurrence relation is
y Many counting problems cannot be solved
a n = an− 1 + d n ≥ 1 , a0 = a
easily; one such problem can be easily
solved by a recurrence relation.
2. For the geometric progression {a, ar, ar2,
y A recurrence relation is a formula which
ar3 …}. The recurrence relation is
relates an with one or more preceding
terms (previous term) an–1, an–2 … . Where a n = (an− 1 ) ⋅ r n ≥ 1 , a0 = a
a0, a1, a2 be a sequence of real numbers.

Examples: 3. For the Fibonacci series < 1, 1, 2, 3, 5, 8, 13,


…} The recurrence relations is
1. For the arithmetic progression {a, a + d, a
+ 2d, …}, and d is a common difference. an =
an− 1 + an−2 n ≥ 2 , a0 = 1 a1 = 1

Solved Examples

22. The number of bacteria in a colony Solution:


doubles every hour. If a colony begins
an = n × an – 1
with five bacteria, how many will be
present in n hours? Using substitution method
Solution: a1 = 1.a0 = 1(1) = 1! Put (n = 1)
Let an be the number of bacteria at the end a2 = 2.a1 = 2(1!) = 2! Put (n = 2)
of n hours.
a3 = 3.a2 = 3(2!) = 3! Put (n = 3)
and an–1 be the number of bacteria after n – 1

hours.
Since the number of bacteria doubles every an = n!
hour.
Then the recurrence relation is:
Linear homogenous recurrence relation:
an = 2an− 1 where a0 = 5.
A linear recurrence relation of degree (order)
k with constant coefficients is a recurrence
relation of the form.
Rack Your Brain
C0an + C1an− 1 + ... + Ck an⋅k =
f(n)
Write the recurrence relation of the
binary string of length n which does not When f(n) = 0 then it homogenous linear
contain two consecutive zeros. recurrence relation and if f(n) ¹ 0 then non
homogenous linear recurrence relation.
Types of recurrence relation:
There are two types of recurrence relation:
� Linear homogenous recurrence relation Rack Your Brain
� Non-linear homogenous recurrence
relation
What is the solution of the recurrence
23. What is the solution of the recurrence relation an = an–1 + 3n–1 where a0 = 1?
relation an = n × an – 1 where a0 = 1?

Counting 95
Characteristic equation for homogenous Characteristic equation for non-homogenous
recurrence relation: linear recurrence relation (f(n)¹ 0):
� If the roots are real and distinct � If f(n) = C(b)n and b is not root of C(t)
an anH + anP
= where anH is solution of
C1t1n + C2t2n + … + Cktkn
homogenous linear recurrence relation
� If the roots are real and equal (two roots and anP is particular solution (depends on
are equal) the form of f(n)).

(C1 + C2n) t1n + C3t3n + … + Cktkn � f(n) = C(b)n and b is not root of C(t)

anP = D(b)n
� If all the rots are real and equal
� f(n) = C(b)n and b is root of C(t) of
(C1 + C2n + C3n + … + Ckn ) t
2 k
1
n
multiplicity m.

� If roots are complex (a ± ib) anP = Dnm (b)n


gn(C1 cos nq + C2 sin nq) where γ = α2 + β2
24. Solve the following non-linear
β
and θ =tan−1   homogenous recurrence relation using
α
characteristic method.
an – 3an – 1 = 7(2)n
23. Solve the following linear homogenous
Solution:
recurrence relation by using characteristic
an = anH + anP
root method.
an – 3an – 1 + 2an – 2 = 0 an(H) = an – 3an – 1 = 0
C(t) = t – 3 = 0
Solution:
Characteristic equation t=3
C(t) = t2 – 3t1 + 2t0 = 0
an (H) = C1 (3)n
t2 – 3t + 2 = 0
(t – 2) (t – 1) = 0 an(P) = f(n) = 7(2)n and 2 is not root of C(t)

t = 2, 1 an(P) = D(2)n
Put this in an – 3an – 1 = 7(2)n
Since the roots are real and distinct.
D(2)n – 3D(2)n – 1 = 7(2)n
So, an = C1(2)n + C2(1)n. 2n – 1 [2D – 3D] = 7(2)n
–D = 7 × 2

D = −14
Rack Your Brain
an(P) = –14(2)n
Write the recurrence relation of binary an = anH + anP
string of length n. Which do not contain
two consecutive zero. an C1 (3)n − 14(2)n
=

96 Counting
Chapter Summary

With no With Unlimited With Limited


Repetition Repetition Repetition

np nr n!
Permutation r
n1 ! ⋅ n2 ! 

n
Generating
Combination Cr n− 1+r
Cr function
y The number of combinations (selections) of n different things taking r at a time is
considered as a combination. It is written as n Cr (n choose r)

n n!
C(n,=
r) Cr
=
r !(n − r) !
y Selecting r objects out of n is the same as selecting (n-r) object out of n
n
Cr = nCc −r
{k-selection equal to k rejection} n
y Total selections that can be made from ‘n’ distinct items is given ∑
k =0
n
Ck = 2n
n n− 1
y = Cr Cr + n− 1Cr − 1
y The total number of selections of one or more objects from n different objects
=2n − 1 =(n C1 + nC2 + nC3 + ... + nCn )
y Total ways to select any number of items from n identical items
= n + 1 (when selection of 0 things is allowed)
=n (when at least one thing is to be selected)
y The total number of selections from p like things, q like things of another type, and r
distinct things
= (p + 1) (q + 1)2r – 1 (if at least one thing is to be selected)
= (p + 1) (q + 1)2r – 2 (if none or all cannot be selected)
y The total number of selections of r things from n different things when each thing can
be repeated an unlimited number of times = n − 1 + r C .
r
y Derangement is an arrangement such that no item should be there in its correct
position
n
n!
Dn
= ∑ (−1)
r =2
r
r!

y The coefficient of x1n1 x2n2  xtnt in the expansion of (x1 + x2 + … xt)n

n!
where n = n1 + n2 + … nt is
n1 !n2 !  nt !
y The number of shortest paths from point (i, j) to a point (p, q) is (p + q – i – j)C
p −i

Counting 97
Inclusion-exclusion principle:
y n (A ∪ B)= n (A) + n (B) − n (A ∩ B)
y n (A ∪ B ∪ C)
= n (A) + n (B) + n (C) − n (A ∩ B) − n (B ∩ C) − n (A ∩ C) + n (A ∩ B ∩ C)
y n (A ⊕ B)= n (A) − n (A ∩ B)
y n (A − B)= n (A) − n (A ∩ B)
y n (B − A)= n (B) − n (A ∩ B)
y n (A ∩ B)= n (∪) − n (A ∪ B)
y n (A ∪ B)= n (∪) − n (A ∩ B)

98 Counting

You might also like