31
Main rules Arrangements and permutations Combinations N.I. Lobachevsky State University of Nizhni Novgorod Probability theory and mathematical statistics: Combinatorics / Art of Counting Associate Professor A.V. Zorine Combinatorics / Art of Counting 1 / 17

N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

N.I. Lobachevsky State Universityof Nizhni Novgorod

Probability theory and mathematical statistics:

Combinatorics / Art of Counting

Associate ProfessorA.V. Zorine

Combinatorics / Art of Counting 1 / 17

Page 2: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Restaurant problemYou’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks andcucumbers, three choices for the main course: a soup, a meat, or a fish, and two for dessert: icecream or tea. How many possible choices do you have for your complete meal?

Choice tree

(start)

cucumbers salad

soupice cream

tea

meat ice creamtea

fish ice creamtea

crab sticks salad

soupice cream

tea

meat ice creamtea

fish ice creamtea

Total number of meals is

(2 + 2 + 2) + (2 + 2 + 2) = 3 · 2 + 3 · 2 = 2 · 3 · 2 = 12.

Combinatorics / Art of Counting 2 / 17

Page 3: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Restaurant problemYou’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks andcucumbers, three choices for the main course: a soup, a meat, or a fish, and two for dessert: icecream or tea. How many possible choices do you have for your complete meal?

Choice tree

(start)

cucumbers salad

soupice cream

tea

meat ice creamtea

fish ice creamtea

crab sticks salad

soupice cream

tea

meat ice creamtea

fish ice creamtea

Total number of meals is

(2 + 2 + 2) + (2 + 2 + 2) = 3 · 2 + 3 · 2 = 2 · 3 · 2 = 12.

Combinatorics / Art of Counting 2 / 17

Page 4: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

General rules of combinatorics

Many problems in probability theory require that we count the number of ways that a particularevent can occur.

Summation theorem

If you can divide items into classes K1, K2, . . . , Km of size N1, N2, . . . , Nm respectively, then thetotal number of items is N1 + N2 + . . . + Nm.

Multiplication theorem

A task can be carried out in k stages. There are n1 ways to carry out the first stage; for each ofthese n1 ways there are n2 ways to carry out the second stage; for each of these ways to carryout the first and the second stage, there are n3 ways to carry out the third stage and so on. Thethe total number of ways in which the entire task can be accomplished is given by the productN = n1 · n2 · n3 · · · nk .

Combinatorics / Art of Counting 3 / 17

Page 5: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. 5 paths lead to the mountain. There are 5 · 5 = 25 ways to go up and down themountain. There are 5 · 4 = 20 ways to go up and down the mountain following different paths.

Example. 1500 people live in a village. At least two of them should have the same initialsletters in their first name and last name. Indeed, Russian alphabet consists of 33 letters, so therecan be only 33 · 33 = 1089 different pair of initials.

Example. A secret lock in a safe has two disks with numbers from 0 to 9 and two disks withletters from A to Z. How many trials would it take a burglar to open it in the worst case?

(Answer: 10 · 26 · 26 · 10 = 67600)

Combinatorics / Art of Counting 4 / 17

Page 6: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. 5 paths lead to the mountain. There are 5 · 5 = 25 ways to go up and down themountain. There are 5 · 4 = 20 ways to go up and down the mountain following different paths.

Example. 1500 people live in a village. At least two of them should have the same initialsletters in their first name and last name. Indeed, Russian alphabet consists of 33 letters, so therecan be only 33 · 33 = 1089 different pair of initials.

Example. A secret lock in a safe has two disks with numbers from 0 to 9 and two disks withletters from A to Z. How many trials would it take a burglar to open it in the worst case?

(Answer: 10 · 26 · 26 · 10 = 67600)

Combinatorics / Art of Counting 4 / 17

Page 7: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

An ordered sample of k items out of n is called arrangement. We have an arrangement withoutrepetitions if every item in an arrangement occurs only once, otherwise we have an arrangementwith repetitions.

Example

We can make twenty-four arrangements (without repetitions) of 3 letters out of the four lettersA, B, C, D:

ABC, BAC, ACB, CAB, CBA, BCA,ABD, BAD, ADB, DAB, DBA, BDA,ACD, CAD, ADC, DAC, DCA, CDA,BCD, CBD, BDC, DBC, DCB, CDB;

Denote by Akn the number of arrangements without repetitions of k items out of n. By

multiplication theorem,

Akn =

k factorsz }| {n · (n− 1) · (n− 2) · · · (n− k + 1) .

Denote by Akn the number of arrangements with repetitions of k items out of n items. By

multiplication theorem,Ak

n = nk.

Combinatorics / Art of Counting 5 / 17

Page 8: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. In how many ways can the first and the second prises be given to a class of ten boys,without giving both to the same boy? Boys to receive prises make an ordered sample withoutrepetitions of 2 persons out of 10, thus there are A2

10 = 10 · 9 = 90 ways to do that.

Example. Two persons got into a bus where there are six vacant seats. In how many differentways can they seat themselves? A2

6 = 6 · 5 = 30.

Example. A chess board has 8 vertical and 8 horizontal rows of squares, 64 squares in total.How many ways are there to place 8 rooks so that they don’t attack each other?

Each row should hold a singlerook. So, a rook in the firsthorizontal row is placed on oneof 8 squares, a rook in the secondhorizontal row is placed on oneof 7 free squares, etc. The totalnumber of possible positions is8 · 7 · 6 · 5 · 4 · 3 · 2 · 1 = 40 320.

Combinatorics / Art of Counting 6 / 17

Page 9: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. In how many ways can the first and the second prises be given to a class of ten boys,without giving both to the same boy? Boys to receive prises make an ordered sample withoutrepetitions of 2 persons out of 10, thus there are A2

10 = 10 · 9 = 90 ways to do that.

Example. Two persons got into a bus where there are six vacant seats. In how many differentways can they seat themselves? A2

6 = 6 · 5 = 30.

Example. A chess board has 8 vertical and 8 horizontal rows of squares, 64 squares in total.How many ways are there to place 8 rooks so that they don’t attack each other?

Each row should hold a singlerook. So, a rook in the firsthorizontal row is placed on oneof 8 squares, a rook in the secondhorizontal row is placed on oneof 7 free squares, etc. The totalnumber of possible positions is8 · 7 · 6 · 5 · 4 · 3 · 2 · 1 = 40 320.

Combinatorics / Art of Counting 6 / 17

Page 10: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. In how many ways can the first and the second prises be given to a class of ten boys,without giving both to the same boy? Boys to receive prises make an ordered sample withoutrepetitions of 2 persons out of 10, thus there are A2

10 = 10 · 9 = 90 ways to do that.

Example. Two persons got into a bus where there are six vacant seats. In how many differentways can they seat themselves? A2

6 = 6 · 5 = 30.

Example. A chess board has 8 vertical and 8 horizontal rows of squares, 64 squares in total.How many ways are there to place 8 rooks so that they don’t attack each other?

Each row should hold a singlerook. So, a rook in the firsthorizontal row is placed on oneof 8 squares, a rook in the secondhorizontal row is placed on oneof 7 free squares, etc. The totalnumber of possible positions is8 · 7 · 6 · 5 · 4 · 3 · 2 · 1 = 40 320.

Combinatorics / Art of Counting 6 / 17

Page 11: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

An arrangement of all items without repetitions is called a permutation.

The number of permutations of n items is

Ann = n · (n− 1) · (n− 2) · · · 1 = n!

(pronounces as ’n-factorial’). For example,

1! = 1, 2! = 2, 3! = 3 · 2 · 1 = 6,

4! = 4 · 3 · 2 · 1 = 4 · 3! = 24, . . . , 10! = 3628800, . . .

Observe that n! = n · (n− 1)!.

Akn = n(n− 1) · · · (n− k + 1) =

n(n− 1) · · · (n− k + 1)(n− k) · · · 2 · 1(n− k) · · · 2 · 1

=n!

(n− k)!

Combinatorics / Art of Counting 7 / 17

Page 12: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Example. ”Placing balls into cells” amount to choosing one cell for each ball. With k balls wehave k independent choices, and therefore k balls can be placed into n cells in nk different ways.(Example of arrangement with repetitions)

Example. How many numbers can be expressed using k digits in base d > 1? Any suchnumber can be regarded as an arrangement with repetitions of k digits, hence the answer is dk .

Combinatorics / Art of Counting 8 / 17

Page 13: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

Suppose we have items e1, e2, . . . , en. Consider unordered samples of size k, 0 6 k 6 nwithout repetitions (no item occurs twice in a sample). These samples are called combinations.

Example

Suppose we choose 3 letters out of 5 letters ’a’, ’b’, ’c’, ’d’, ’e’. Possible combinations (orselections) are:{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d},{a, c, e}, {a, d, e}, {b, c, d}, {b, c, e},{b, d, e}, {c, d, e}.

Denote Ckn the number of all combinations of k objects out of n. In the example above C2

5 = 10.Let’s find a recurrent formula for Ck

n. If k = 0, only one empty combination is possible,C0

n = 1. If k = n, only one combination containing all elements is possible, Cnn = 1.

Assume now k > 1. Divide all combinations into two classes. Let the first class containcombinations with e1. So we have to choose (k − 1) elements out of (n− 1). Hence there areCk−1

n−1 items in this class. The second class has the rest. Each combination from the secondclass includes only some of the elements e2, e3, . . . , en. There are Ck

n−1 such combinations.

Hence Ckn = Ck−1

n−1 + Ckn−1.

Combinatorics / Art of Counting 9 / 17

Page 14: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

Suppose we have items e1, e2, . . . , en. Consider unordered samples of size k, 0 6 k 6 nwithout repetitions (no item occurs twice in a sample). These samples are called combinations.

Example

Suppose we choose 3 letters out of 5 letters ’a’, ’b’, ’c’, ’d’, ’e’. Possible combinations (orselections) are:{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d},{a, c, e}, {a, d, e}, {b, c, d}, {b, c, e},{b, d, e}, {c, d, e}.

Denote Ckn the number of all combinations of k objects out of n. In the example above C2

5 = 10.Let’s find a recurrent formula for Ck

n. If k = 0, only one empty combination is possible,C0

n = 1. If k = n, only one combination containing all elements is possible, Cnn = 1.

Assume now k > 1. Divide all combinations into two classes. Let the first class containcombinations with e1. So we have to choose (k − 1) elements out of (n− 1). Hence there areCk−1

n−1 items in this class. The second class has the rest. Each combination from the secondclass includes only some of the elements e2, e3, . . . , en. There are Ck

n−1 such combinations.

Hence Ckn = Ck−1

n−1 + Ckn−1.

Combinatorics / Art of Counting 9 / 17

Page 15: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

Suppose we have items e1, e2, . . . , en. Consider unordered samples of size k, 0 6 k 6 nwithout repetitions (no item occurs twice in a sample). These samples are called combinations.

Example

Suppose we choose 3 letters out of 5 letters ’a’, ’b’, ’c’, ’d’, ’e’. Possible combinations (orselections) are:{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d},{a, c, e}, {a, d, e}, {b, c, d}, {b, c, e},{b, d, e}, {c, d, e}.

Denote Ckn the number of all combinations of k objects out of n. In the example above C2

5 = 10.Let’s find a recurrent formula for Ck

n. If k = 0, only one empty combination is possible,C0

n = 1. If k = n, only one combination containing all elements is possible, Cnn = 1.

Assume now k > 1. Divide all combinations into two classes. Let the first class containcombinations with e1. So we have to choose (k − 1) elements out of (n− 1). Hence there areCk−1

n−1 items in this class.

The second class has the rest. Each combination from the secondclass includes only some of the elements e2, e3, . . . , en. There are Ck

n−1 such combinations.

Hence Ckn = Ck−1

n−1 + Ckn−1.

Combinatorics / Art of Counting 9 / 17

Page 16: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

Suppose we have items e1, e2, . . . , en. Consider unordered samples of size k, 0 6 k 6 nwithout repetitions (no item occurs twice in a sample). These samples are called combinations.

Example

Suppose we choose 3 letters out of 5 letters ’a’, ’b’, ’c’, ’d’, ’e’. Possible combinations (orselections) are:{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d},{a, c, e}, {a, d, e}, {b, c, d}, {b, c, e},{b, d, e}, {c, d, e}.

Denote Ckn the number of all combinations of k objects out of n. In the example above C2

5 = 10.Let’s find a recurrent formula for Ck

n. If k = 0, only one empty combination is possible,C0

n = 1. If k = n, only one combination containing all elements is possible, Cnn = 1.

Assume now k > 1. Divide all combinations into two classes. Let the first class containcombinations with e1. So we have to choose (k − 1) elements out of (n− 1). Hence there areCk−1

n−1 items in this class. The second class has the rest. Each combination from the secondclass includes only some of the elements e2, e3, . . . , en. There are Ck

n−1 such combinations.

Hence Ckn = Ck−1

n−1 + Ckn−1.

Combinatorics / Art of Counting 9 / 17

Page 17: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Definition

Suppose we have items e1, e2, . . . , en. Consider unordered samples of size k, 0 6 k 6 nwithout repetitions (no item occurs twice in a sample). These samples are called combinations.

Example

Suppose we choose 3 letters out of 5 letters ’a’, ’b’, ’c’, ’d’, ’e’. Possible combinations (orselections) are:{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d},{a, c, e}, {a, d, e}, {b, c, d}, {b, c, e},{b, d, e}, {c, d, e}.

Denote Ckn the number of all combinations of k objects out of n. In the example above C2

5 = 10.Let’s find a recurrent formula for Ck

n. If k = 0, only one empty combination is possible,C0

n = 1. If k = n, only one combination containing all elements is possible, Cnn = 1.

Assume now k > 1. Divide all combinations into two classes. Let the first class containcombinations with e1. So we have to choose (k − 1) elements out of (n− 1). Hence there areCk−1

n−1 items in this class. The second class has the rest. Each combination from the secondclass includes only some of the elements e2, e3, . . . , en. There are Ck

n−1 such combinations.

Hence Ckn = Ck−1

n−1 + Ckn−1.

Combinatorics / Art of Counting 9 / 17

Page 18: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Calculating Ckn

It’s useful to write all Ckn in a triangular form

n = 1 C01 C1

1n = 2 C0

2 C12 C2

2n = 3 C0

3 C13 C2

3 C33

n = 4 C04 C1

4 C24 C3

4 C44

n = 5 C05 C1

5 C25 C3

5 C55 C5

5n = 6 C0

6 C16 C2

6 C36 C4

6 C56 C0

6. . . . . . . . . . . . . . . . . . . . .

Combinatorics / Art of Counting 10 / 17

Page 19: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Calculating Ckn

We know that there’s only 1 way to choose one item out of one

n = 1 1 1n = 2 C0

2 C12 C2

2n = 3 C0

3 C13 C2

3 C33

n = 4 C04 C1

4 C24 C3

4 C44

n = 5 C05 C1

5 C25 C3

5 C55 C5

5n = 6 C0

6 C16 C2

6 C36 C4

6 C56 C0

6. . . . . . . . . . . . . . . . . . . . .

Combinatorics / Art of Counting 10 / 17

Page 20: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Calculating Ckn

Use the first line to calculate the second line: C02 = 1, Ck

2 = Ck−11 + Ck

1

n = 1 1 1n = 2 1 2 1n = 3 C0

3 C13 C2

3 C33

n = 4 C04 C1

4 C24 C3

4 C44

n = 5 C05 C1

5 C25 C3

5 C55 C5

5n = 6 C0

6 C16 C2

6 C36 C4

6 C56 C0

6. . . . . . . . . . . . . . . . . . . . .

Combinatorics / Art of Counting 10 / 17

Page 21: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Calculating Ckn

Use the second line to calculate the third line: C03 = 1, Ck

3 = Ck−12 + Ck

2

n = 1 1 1n = 2 1 2 1n = 3 1 3 3 1n = 4 C0

4 C14 C2

4 C34 C4

4n = 5 C0

5 C15 C2

5 C35 C5

5 C55

n = 6 C06 C1

6 C26 C3

6 C46 C5

6 C06

. . . . . . . . . . . . . . . . . . . . .

Combinatorics / Art of Counting 10 / 17

Page 22: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Calculating Ckn

Calculate the rest in similar manner. We obtain the Pascal triangle:

n = 1 1 1n = 2 1 2 1n = 3 1 3 3 1n = 4 1 4 6 4 1n = 5 1 5 10 10 5 1n = 6 1 6 15 20 15 6 1

. . . . . . . . . . . . . . . . . . . . .

Properties of binomial coefficients:

Ckn = Cn−k

n (symmetry)

C0n + C1

n + . . . + Cnn = 2n

Combinatorics / Art of Counting 10 / 17

Page 23: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Newton’s binomial formula

a + b = C01a + C1

1b,

(a + b)2 = (a + b)(C01a + C0

1b) = C01a2 + (C0

1 + C11)ab + C1

1b2

= C02a2 + C1

2ab + C22b2,

(a + b)3 = (a + b)(C02a2 + C1

2ab + C22b2) = C0

2a3 + (C02 + C1

2)a2b + (C12 + C2

2)ab2 + C22b3 =

= C03a3 + C1

3a2b + C23ab2 + C3

3b3,

. . .

(a + b)n = C0nan + C1

nan−1b + C2nan−2b2 + . . . + Cn−1

n abn−1 + Cnnbn.

Put a = 1, b = 1, immediately obtain C0n + C1

n + . . . + Cnn = 2n.

Put a = 1, b = −1, then C0n − C1

n + C2n − C3

n + . . . + (−1)nCnn = 0.

Combinatorics / Art of Counting 11 / 17

Page 24: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Theorem

Ckn =

n · (n− 1) · · · (n− k + 1)

k · (k − 1) · · · 1for n > 1 and k = 1, 2, . . . , n.

Proof

Ck−1n−1 + Ck

n−1 =

k − 1 factorsz }| {(n− 1)(n− 2) · · · (n− 1− (k − 1) + 1)

(k − 1)(k − 2) · · · 1

+

k factorsz }| {(n− 1)(n− 2) · · · (n− 1− k + 1)

k(k − 1)(k − 2) · · · 1

=(n− 1)(n− 2) · · · (n− 1− (k − 1) + 1)

(k − 1)(k − 2) · · · 1

“1 +

n− kk

”=

n(n− 1)(n− 2) · · · (n− k + 1)

k(k − 1)(k − 2) · · · 1.

Combinatorics / Art of Counting 12 / 17

Page 25: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Ckn =

n · (n− 1) · · · (n− k + 1)

k · (k − 1) · · · 1=

n!

k!(n− k)!

This formula is useful for large n, k. For this formula to be exact, assume 0! = 1. Let’s computeC50

100 using logarithms (base 10):

lg 100! = 157,9700,

lg 50! = 64,4831,

lg(50!)2 = 128,9662,

lg C50100 = lg

100!

50!50!= lg 100!− lg(50!)2 = 29,0038,

C50100 = 1029,0038 = 1,008788214949312 · 1029.

In fact, C50100 = 100 891 344 545 564 193 334 812 497 256, relative error is less than 0,012%.

Combinatorics / Art of Counting 13 / 17

Page 26: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Choosing from items of two types

Problem. Suppose we have a red balls and b blue balls in an urn and r balls are taken out. Howmany combinations contain exactly k red balls?

Solution. We see that there should be (r − k) blue balls in a sample. There are Cka ways to

choose k red balls and Cr−kb ways to choose r − k blue balls. Hence the total number of

combinations is CkaCr−k

b .

Another property of binomial coefficients

For integer a, b, and r 6 min{a, b}

C0aCr

b + C1aCr−1

b + C2aCr−2

b + . . . + CraC0

b = Cra+b

Proof. A combination of r balls out of a red balls and b blue balls has either 0 red balls, orexactly 1 red ball, or exactly 2 red balls, and so on up to exactly r red balls (thus we have r + 1classes). Now we use summation theorem.

Combinatorics / Art of Counting 14 / 17

Page 27: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Choosing from items of two types

Problem. Suppose we have a red balls and b blue balls in an urn and r balls are taken out. Howmany combinations contain exactly k red balls?

Solution. We see that there should be (r − k) blue balls in a sample. There are Cka ways to

choose k red balls and Cr−kb ways to choose r − k blue balls. Hence the total number of

combinations is CkaCr−k

b .

Another property of binomial coefficients

For integer a, b, and r 6 min{a, b}

C0aCr

b + C1aCr−1

b + C2aCr−2

b + . . . + CraC0

b = Cra+b

Proof. A combination of r balls out of a red balls and b blue balls has either 0 red balls, orexactly 1 red ball, or exactly 2 red balls, and so on up to exactly r red balls (thus we have r + 1classes). Now we use summation theorem.

Combinatorics / Art of Counting 14 / 17

Page 28: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Paths on lattices

How many paths lead from (0, 0) to (m, n) going either up or right along the grid?

(0, 0)

(6, 4)

Obviously, every path consists of m + n unit steps upwards or rightwards. If we choose mparticular steps to go to the right, we completely define the path. Hence there are Cm

m+ndifferent paths.

Combinatorics / Art of Counting 15 / 17

Page 29: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Random walk on a line

A particle starts from zero and make one unit step per time 1 second. It moves either left orright. How many paths return to zero after 2n seconds?

0−1 1 2 . . . i− 1 i i + 1

A path returns to zero after 2n seconds if an only if n steps are to the left and n steps are to theright. There are Cn

2n possible paths.

Combinatorics / Art of Counting 16 / 17

Page 30: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Random walk on a line

A particle starts from zero and make one unit step per time 1 second. It moves either left orright. How many paths return to zero after 2n seconds?

0−1 1 2 . . . i− 1 i i + 1

A path returns to zero after 2n seconds if an only if n steps are to the left and n steps are to theright. There are Cn

2n possible paths.

Combinatorics / Art of Counting 16 / 17

Page 31: N.I. Lobachevsky State University of Nizhni Novgorodzoav1/classes/it/lecture01.pdf · You’re eating at ’Proschaj, Tovarisch!’ and you have two choices for salads: crab sticks

Main rulesArrangements and permutations

Combinations

Recurrent equations

We had an example before: recurrent equation Ckn = Ck−1

n−1 + Ckn−1 for binomial coefficients.

We’ll use the same idea to solve a couple more problems.

Barrel problem. You have an 8-gallon barrel and two buckets, one for 1 gallon and one for 2gallons. In how many ways can you empty the barrel?

We can use 1 gallon bucket 8 times, or 2 gallon bucket 4 times; 1 gallon bucket 2 times and 2gallon bucket 3 times; 2 gallon bucket, then 1 gallon bucket twice, then 2 gallon bucket twiceetc. Denote FN the number of ways to empty N gallon barrel. Obviously, F1 = 1, F2 = 2(2 = 1 + 1). For N > 2, first we may use 1 gallon bucket and then empty N − 1 gallon barrel;or use 2 gallon bucket and then empty N − 2 gallon barrel. The total number of ways is a sumof FN−1 and NN−2:

FN = FN−1 + FN−2.

Then fill the table:

F1 F2 F3 F4 F5 F6 F7 F81 2 3 5 8 13 21 34

The answer is in bold face.

Combinatorics / Art of Counting 17 / 17