126
Permutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem

Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

  • Upload
    others

  • View
    27

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations, Combinations and theBinomial Theorem

November 24, 2010

Permutations, Combinations and the Binomial Theorem

Page 2: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutation, revisited

DefinitionAn r-permutation from n distinct objects is an ordered selectionof r objects from the given n objects.

RemarkBy the product rule, there are n · (n − 1) · . . . · (n − r + 1)different ways to select r objects.

ExampleThere are 27 students in our class. In how many ways can wechoose a class leader, a class organizer and a class treasurerto form the class committee?

AnswerThis task can be performed in 27 · 26 · 25 different ways.

Permutations, Combinations and the Binomial Theorem

Page 3: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutation, revisited

DefinitionAn r-permutation from n distinct objects is an ordered selectionof r objects from the given n objects.

RemarkBy the product rule, there are n · (n − 1) · . . . · (n − r + 1)different ways to select r objects.

ExampleThere are 27 students in our class. In how many ways can wechoose a class leader, a class organizer and a class treasurerto form the class committee?

AnswerThis task can be performed in 27 · 26 · 25 different ways.

Permutations, Combinations and the Binomial Theorem

Page 4: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutation, revisited

DefinitionAn r-permutation from n distinct objects is an ordered selectionof r objects from the given n objects.

RemarkBy the product rule, there are n · (n − 1) · . . . · (n − r + 1)different ways to select r objects.

ExampleThere are 27 students in our class. In how many ways can wechoose a class leader, a class organizer and a class treasurerto form the class committee?

AnswerThis task can be performed in 27 · 26 · 25 different ways.

Permutations, Combinations and the Binomial Theorem

Page 5: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutation, revisited

DefinitionAn r-permutation from n distinct objects is an ordered selectionof r objects from the given n objects.

RemarkBy the product rule, there are n · (n − 1) · . . . · (n − r + 1)different ways to select r objects.

ExampleThere are 27 students in our class. In how many ways can wechoose a class leader, a class organizer and a class treasurerto form the class committee?

AnswerThis task can be performed in 27 · 26 · 25 different ways.

Permutations, Combinations and the Binomial Theorem

Page 6: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)

1 9 7 11 1 5 4 2 3 6 10 8 122 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 7: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)

1 9 7 11 1 5 4 2 3 6 10 8 122 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 8: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)

1 9 7 11 1 5 4 2 3 6 10 8 122 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 9: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)

1 9 7 11 1 5 4 2 3 6 10 8 122 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 10: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)1 9 7 11 1 5 4 2 3 6 10 8 12

2 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 11: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Permutations and Sorting

One of the most frequent activities of computers in largecorporations is sorting. Needless to say that it is very importantto devise sorting programs that will be as efficient as possible.In many applications it is not unusual to have millions of recordsthat need to be sorted.We shall assume that a sorted sequence is a monotonicallyincreasing sequence.

DefinitionAn inversion in a permutation a1a2 . . . an is a pair of entriesai ,aj such that i < j , and ai > aj

Example (How many inversions are in these permutation?)1 9 7 11 1 5 4 2 3 6 10 8 122 12 8 10 6 3 2 4 5 1 11 7 9

Permutations, Combinations and the Binomial Theorem

Page 12: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer

1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 13: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer

1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 14: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer

1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 15: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer1 There are n! distinct permutations.

2 A permutation can have 0 inversions (sorted) or(n

2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 16: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 17: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 18: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

RemarkA sorted sequence (array) is a sequence with no inversions.Thus the goal of a sorting procedure is to remove all inversionsfrom the given sequence.

QuestionWhat is the average number of inversions in an n-permutation?

Answer1 There are n! distinct permutations.2 A permutation can have 0 inversions (sorted) or

(n2

)inversions or any number in between.

3 The average number of inversions in a randompermutation is the total number of inversions in all n!permutations divided by n!.

4 But how can we find the total number?

Permutations, Combinations and the Binomial Theorem

Page 19: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.

2 We pair every permutation a1a2 . . . an−1an with its reverseanan−1 . . . a2a1.

3 We have n!2 disjoint pairs.

4 Each pair accounts for(n

2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 20: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.

3 We have n!2 disjoint pairs.

4 Each pair accounts for(n

2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 21: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.

4 Each pair accounts for(n

2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 22: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.4 Each pair accounts for

(n2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 23: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.4 Each pair accounts for

(n2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 24: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.4 Each pair accounts for

(n2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 25: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.4 Each pair accounts for

(n2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 26: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 We shall count the total number of inversions in pairs.2 We pair every permutation a1a2 . . . an−1an with its reverse

anan−1 . . . a2a1.3 We have n!

2 disjoint pairs.4 Each pair accounts for

(n2

)inversions.

5 So the average number of inversions in an n-permutationis: 1

n!

(n2

)· n!

2 = n(n−1)4

RemarkIf we exchange ai and ai+1 we remove 1 inversion.

So on the average, we’ll have to perform n(n−1)4 such

exchanges.

Better sorting programs compare records that are far apart thuscapable of removing more inversions in one exchange.

Permutations, Combinations and the Binomial Theorem

Page 27: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Sorting

Let us try to see what is the most efficient execution for sorting5 objects. The best model for analyzing this problem seems tobe the decision tree model.

The decision tree for this problem (a binary tree) will have tohave 5! leaves.This means that its depth will have to be at least 7.

QuestionCan we design a sorting algorithm that will sort any given 5objects in no more than 7 comparisons?

QuestionFor a fixed integer n what is the smallest number ofcomparisons a sorting algorithm needs to execute to sort anyinput list of n objects?

Permutations, Combinations and the Binomial Theorem

Page 28: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Sorting

Let us try to see what is the most efficient execution for sorting5 objects. The best model for analyzing this problem seems tobe the decision tree model.The decision tree for this problem (a binary tree) will have tohave 5! leaves.

This means that its depth will have to be at least 7.

QuestionCan we design a sorting algorithm that will sort any given 5objects in no more than 7 comparisons?

QuestionFor a fixed integer n what is the smallest number ofcomparisons a sorting algorithm needs to execute to sort anyinput list of n objects?

Permutations, Combinations and the Binomial Theorem

Page 29: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Sorting

Let us try to see what is the most efficient execution for sorting5 objects. The best model for analyzing this problem seems tobe the decision tree model.The decision tree for this problem (a binary tree) will have tohave 5! leaves.This means that its depth will have to be at least 7.

QuestionCan we design a sorting algorithm that will sort any given 5objects in no more than 7 comparisons?

QuestionFor a fixed integer n what is the smallest number ofcomparisons a sorting algorithm needs to execute to sort anyinput list of n objects?

Permutations, Combinations and the Binomial Theorem

Page 30: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Sorting

Let us try to see what is the most efficient execution for sorting5 objects. The best model for analyzing this problem seems tobe the decision tree model.The decision tree for this problem (a binary tree) will have tohave 5! leaves.This means that its depth will have to be at least 7.

QuestionCan we design a sorting algorithm that will sort any given 5objects in no more than 7 comparisons?

QuestionFor a fixed integer n what is the smallest number ofcomparisons a sorting algorithm needs to execute to sort anyinput list of n objects?

Permutations, Combinations and the Binomial Theorem

Page 31: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 32: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.

3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 33: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 34: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 35: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 36: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 The decision tree model for analyzing sorting will have tobe a tree with n! leaves.

2 This means that the height of the tree is ≥ dlog n!e.3

log n! =n∑

k=1

log k ≤ n log n

4

log n! >n∑

k> n2

log k >14

n log n

We do have sorting algorithms that execute about c · n log ncomparisons.

Permutations, Combinations and the Binomial Theorem

Page 37: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Enumerating Permutations

In many applications, for instance if we need to generaterandom permutations we need to enumerate permutations.

That is we need to find a bijection f : Sn → {0,1, . . . (n!− 1)}.

Permutations, Combinations and the Binomial Theorem

Page 38: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Enumerating Permutations

In many applications, for instance if we need to generaterandom permutations we need to enumerate permutations.

That is we need to find a bijection f : Sn → {0,1, . . . (n!− 1)}.

Permutations, Combinations and the Binomial Theorem

Page 39: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Enumerating Permutations

In many applications, for instance if we need to generaterandom permutations we need to enumerate permutations.

That is we need to find a bijection f : Sn → {0,1, . . . (n!− 1)}.

Permutations, Combinations and the Binomial Theorem

Page 40: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:

n =∑m

i=0 di · ai .There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 41: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 42: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .

Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 43: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.

The representation is unique.2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 44: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 45: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:

3 Decimal (common) n =∑m

k=0 ak · 10k 0 ≤ ak ≤ 94 Example:

150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 46: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 47: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 48: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.

6 Base b representation: n =∑m

i=1 di · bi 0 ≤ di < b.7 Cantor Digits: n =

∑mk=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 49: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 50: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

There are many different representations of integers:1 In general, given a sequence α = a1,a2, . . .

An α representation of the integer n is:n =

∑mi=0 di · ai .

There are restrictions on the coefficients di .Every integer n has such a representation.The representation is unique.

2 Examples:3 Decimal (common) n =

∑mk=0 ak · 10k 0 ≤ ak ≤ 9

4 Example:150436 = 6 · 100 + 3 · 101 + 4 · 102 + 5 · 104 + 1 · 105

5 Binary representation: n =∑m

i=0 di · 2i , di = 0,1.6 Base b representation: n =

∑mi=1 di · bi 0 ≤ di < b.

7 Cantor Digits: n =∑m

k=0 dk · k ! 0 ≤ dk ≤ k .

Permutations, Combinations and the Binomial Theorem

Page 51: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example

1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 52: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!

2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 53: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 54: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 55: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 56: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 57: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Cantor Digits

Example1 1000 = 1 · 6! + 2 · 5! + 1 · 4! + 2 · 3! + 2 · 2!2 So the cantor digits of 1000 are 1 2 1 2 2 0.

RemarkFor an α-representation to be unique it is sufficient thatan+1 >

∑ni=0 di · ai for all possible choices of di .

We need to show that :

TheoremEvery integer m has a unique representation:m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k.

Permutations, Combinations and the Binomial Theorem

Page 58: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).5 That means that

m = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 59: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!

2 Assume m =∑s

k=0 dk · k ! 0 ≤ dk ≤ k .We need to show that m + 1 =

∑sk=0 fk · k ! 0 ≤ fk ≤ k .

3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).5 That means that

m = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 60: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .

3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).5 That means that

m = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 61: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.

4 Let k be the smallest index for which dk < k (such an indexexists).

5 That means thatm = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 62: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).

5 That means thatm = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 63: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).5 That means that

m = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 64: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.

First recall that∑s

k=1 k · k ! = (s + 1)!− 1 so by the previousremark the representation is unique.

We now proceed by induction to prove that every integer has aCantor Digits representation.

1 1 = 1 · 1!2 Assume m =

∑sk=0 dk · k ! 0 ≤ dk ≤ k .

We need to show that m + 1 =∑s

k=0 fk · k ! 0 ≤ fk ≤ k .3 If dk = k ∀k then m = (s + 1)!− 1 and m + 1 = (s + 1)!.4 Let k be the smallest index for which dk < k (such an index

exists).5 That means that

m = 1 · 1! + 2 · 2! + . . .+ (k − 1) · (k − 1)! + dk · k ! + . . .

6 m + 1 = (dk + 1) · k ! + . . . .

Permutations, Combinations and the Binomial Theorem

Page 65: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Enumerating Permutations

Given an n- permutation π = a1a2 . . . an we asociate with it theinteger f (π) =

∑n−1k=1 dk · k !.

The coefficients dk are calculated as follows:

Let aj = k + 1. Then dk = |{aim |im > j and (k + 1) = aj > aim}|

In words: dk is the number of entries in the permutation π thatare to the right of k + 1 and are smaller than k + 1.

ExampleLet π = 7 5 4 6 1 3 2 8.

d1 = 0, d2 = 1, d3 = 3, d4 = 4,d5 = 3,d6 = 6.So f (π) = 6 · 6! + 3 · 5! + 4 · 4! + 3 · 3! + 2!

Permutations, Combinations and the Binomial Theorem

Page 66: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Enumerating Permutations

Given an n- permutation π = a1a2 . . . an we asociate with it theinteger f (π) =

∑n−1k=1 dk · k !.

The coefficients dk are calculated as follows:

Let aj = k + 1. Then dk = |{aim |im > j and (k + 1) = aj > aim}|

In words: dk is the number of entries in the permutation π thatare to the right of k + 1 and are smaller than k + 1.

ExampleLet π = 7 5 4 6 1 3 2 8.

d1 = 0, d2 = 1, d3 = 3, d4 = 4,d5 = 3,d6 = 6.So f (π) = 6 · 6! + 3 · 5! + 4 · 4! + 3 · 3! + 2!

Permutations, Combinations and the Binomial Theorem

Page 67: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 68: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 69: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 70: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 71: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 72: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗

4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 73: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.

5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 74: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.

6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 75: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleLet us calculate the 8-permutation number 20,000.

20000 = 2! + 3! + 3 ∗ 4! + 4 ∗ 5! + 6 ∗ 6! + 3 ∗ 7!(use a simple greedy approach to make this easy calculation).

1 Start with eight ∗ ∗ ∗ ∗ ∗ ∗ ∗∗. Each ∗ will represent one ofthe integers 1,2, . . .8.

2 d7 = 3, so 8 has 3 smaller numbers following it.Place it so that 3 ∗ s follow it: ∗ ∗ ∗ ∗ 8 ∗ ∗∗.

3 Next place 7 so that 6 ∗ s follow it : 7 ∗ ∗ ∗ 8 ∗ ∗∗4 Place i + 1 so that di ∗ s follow it.5 place 1 at the last ∗.6 In our example: f−1(20000) = 7 1 6 5 8 3 4 2.

Permutations, Combinations and the Binomial Theorem

Page 76: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Efficient Generation of Permutations andCombinations

Permutations can be generated either by the lexicographicorder or by the Cantor-Digits enumeration.There is another method called The Arrow algorithm.

1 Start by placing an arrow pointing to the left over eachnumber in the n- permutation:

←−1←−2 . . .

←−n .

2 The next permutation is generated by finding the largestentry whose arrow points to a smaller entry then:

Interchage the two numbers.Reverse the direction of all arrows on numbers greater thisentry.

3 Stop when no arrow above an entry points to a smallerentry.

Permutations, Combinations and the Binomial Theorem

Page 77: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Efficient Generation of Permutations andCombinations

Permutations can be generated either by the lexicographicorder or by the Cantor-Digits enumeration.There is another method called The Arrow algorithm.

1 Start by placing an arrow pointing to the left over eachnumber in the n- permutation:

←−1←−2 . . .

←−n .2 The next permutation is generated by finding the largest

entry whose arrow points to a smaller entry then:

Interchage the two numbers.Reverse the direction of all arrows on numbers greater thisentry.

3 Stop when no arrow above an entry points to a smallerentry.

Permutations, Combinations and the Binomial Theorem

Page 78: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Efficient Generation of Permutations andCombinations

Permutations can be generated either by the lexicographicorder or by the Cantor-Digits enumeration.There is another method called The Arrow algorithm.

1 Start by placing an arrow pointing to the left over eachnumber in the n- permutation:

←−1←−2 . . .

←−n .2 The next permutation is generated by finding the largest

entry whose arrow points to a smaller entry then:Interchage the two numbers.

Reverse the direction of all arrows on numbers greater thisentry.

3 Stop when no arrow above an entry points to a smallerentry.

Permutations, Combinations and the Binomial Theorem

Page 79: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Efficient Generation of Permutations andCombinations

Permutations can be generated either by the lexicographicorder or by the Cantor-Digits enumeration.There is another method called The Arrow algorithm.

1 Start by placing an arrow pointing to the left over eachnumber in the n- permutation:

←−1←−2 . . .

←−n .2 The next permutation is generated by finding the largest

entry whose arrow points to a smaller entry then:Interchage the two numbers.Reverse the direction of all arrows on numbers greater thisentry.

3 Stop when no arrow above an entry points to a smallerentry.

Permutations, Combinations and the Binomial Theorem

Page 80: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Efficient Generation of Permutations andCombinations

Permutations can be generated either by the lexicographicorder or by the Cantor-Digits enumeration.There is another method called The Arrow algorithm.

1 Start by placing an arrow pointing to the left over eachnumber in the n- permutation:

←−1←−2 . . .

←−n .2 The next permutation is generated by finding the largest

entry whose arrow points to a smaller entry then:Interchage the two numbers.Reverse the direction of all arrows on numbers greater thisentry.

3 Stop when no arrow above an entry points to a smallerentry.

Permutations, Combinations and the Binomial Theorem

Page 81: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3

⇒←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 82: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3

⇒←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 83: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2

⇒←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 84: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2

⇒−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 85: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1

⇒←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 86: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1

⇒←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 87: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 88: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 89: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 90: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 91: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

ExampleStart:←−1←−2←−3 ⇒

←−1←−3←−2 ⇒

←−3←−1←−2 ⇒

−→3←−2←−1 ⇒

←−2−→3←−1 ⇒

←−2←−1−→3

Remark (Generating Combinations)

We wish to generate all r -combinations of an n-set{a1,a2, . . . ,an}. We shall proceed lexicographically:{a1,a2, . . .ar} will be the first (“smallest”) and {an−r+1, . . . ,an}be the last (“largest”).

QuestionWhat is the 4-subset of {1,2, . . . ,8} following {3,5,7,8}?

Ans: {3,6,7,8}.

Permutations, Combinations and the Binomial Theorem

Page 92: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Generating Combinations

To simplify the notation, we shall assume that our universal setis {1,2, . . . ,n} and the numbers in the r subsets are sorted.

1 Given an r -subset {a1,a2, . . . ,ar} locate the last index isuch that ai 6= n − r + i .

2 Replace ai with ai + 1 and add the next consecutiveintegers to form the next r -subset.

Example

The 4-combination following the combination {3,5,7,10} in({1,2,...,10}4

)is: {3,5,8,9}.

Permutations, Combinations and the Binomial Theorem

Page 93: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Generating Combinations

To simplify the notation, we shall assume that our universal setis {1,2, . . . ,n} and the numbers in the r subsets are sorted.

1 Given an r -subset {a1,a2, . . . ,ar} locate the last index isuch that ai 6= n − r + i .

2 Replace ai with ai + 1 and add the next consecutiveintegers to form the next r -subset.

Example

The 4-combination following the combination {3,5,7,10} in({1,2,...,10}4

)is: {3,5,8,9}.

Permutations, Combinations and the Binomial Theorem

Page 94: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Generating Combinations

To simplify the notation, we shall assume that our universal setis {1,2, . . . ,n} and the numbers in the r subsets are sorted.

1 Given an r -subset {a1,a2, . . . ,ar} locate the last index isuch that ai 6= n − r + i .

2 Replace ai with ai + 1 and add the next consecutiveintegers to form the next r -subset.

Example

The 4-combination following the combination {3,5,7,10} in({1,2,...,10}4

)is: {3,5,8,9}.

Permutations, Combinations and the Binomial Theorem

Page 95: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

The Binomial theorem

You probably know a few proofs of the classical binoial theorem:

Theorem

(x + y)n =n∑

i=0

(ni

)x iyn−i

(nk

)are the binomial coefficients. A simple counting argument

shows that the number of ways to select a set of k objects froma set of n objects is

(nk

)= n!

k!(n−k)! .There are many interesting relations among the binomialcoefficieints. We shall briefly explore them and also see thetechnique of double counting used to prove many combinatorialidentities. We start with Pascal’s idenitity:

Theorem (Pascal’s Identity)(n + 1

k

)=

(n

k − 1

)+

(nk

)

Permutations, Combinations and the Binomial Theorem

Page 96: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

The Binomial theorem

You probably know a few proofs of the classical binoial theorem:

Theorem

(x + y)n =n∑

i=0

(ni

)x iyn−i

(nk

)are the binomial coefficients. A simple counting argument

shows that the number of ways to select a set of k objects froma set of n objects is

(nk

)= n!

k!(n−k)! .There are many interesting relations among the binomialcoefficieints. We shall briefly explore them and also see thetechnique of double counting used to prove many combinatorialidentities. We start with Pascal’s idenitity:

Theorem (Pascal’s Identity)(n + 1

k

)=

(n

k − 1

)+

(nk

)

Permutations, Combinations and the Binomial Theorem

Page 97: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

The Binomial theorem

You probably know a few proofs of the classical binoial theorem:

Theorem

(x + y)n =n∑

i=0

(ni

)x iyn−i

(nk

)are the binomial coefficients. A simple counting argument

shows that the number of ways to select a set of k objects froma set of n objects is

(nk

)= n!

k!(n−k)! .

There are many interesting relations among the binomialcoefficieints. We shall briefly explore them and also see thetechnique of double counting used to prove many combinatorialidentities. We start with Pascal’s idenitity:

Theorem (Pascal’s Identity)(n + 1

k

)=

(n

k − 1

)+

(nk

)

Permutations, Combinations and the Binomial Theorem

Page 98: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

The Binomial theorem

You probably know a few proofs of the classical binoial theorem:

Theorem

(x + y)n =n∑

i=0

(ni

)x iyn−i

(nk

)are the binomial coefficients. A simple counting argument

shows that the number of ways to select a set of k objects froma set of n objects is

(nk

)= n!

k!(n−k)! .There are many interesting relations among the binomialcoefficieints. We shall briefly explore them and also see thetechnique of double counting used to prove many combinatorialidentities.

We start with Pascal’s idenitity:

Theorem (Pascal’s Identity)(n + 1

k

)=

(n

k − 1

)+

(nk

)

Permutations, Combinations and the Binomial Theorem

Page 99: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

The Binomial theorem

You probably know a few proofs of the classical binoial theorem:

Theorem

(x + y)n =n∑

i=0

(ni

)x iyn−i

(nk

)are the binomial coefficients. A simple counting argument

shows that the number of ways to select a set of k objects froma set of n objects is

(nk

)= n!

k!(n−k)! .There are many interesting relations among the binomialcoefficieints. We shall briefly explore them and also see thetechnique of double counting used to prove many combinatorialidentities. We start with Pascal’s idenitity:

Theorem (Pascal’s Identity)(n + 1

k

)=

(n

k − 1

)+

(nk

)Permutations, Combinations and the Binomial Theorem

Page 100: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 101: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.

2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 102: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.

3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 103: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 104: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 105: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Proof.Here is a simple combinatorial (double counting) proof:

1(n+1

k

)is the number of ways to select k object from a set of

n + 1 objects.2( n

k−1

)is the number of ways to select k objects such that

each selection includes object number n + 1.3(n

k

)is the number of ways to choose k object that do not

include object number n + 1.

This relation among the binomial coefficient is traditionallyencapsulated in the famous Pascal’s triangle.

Permutations, Combinations and the Binomial Theorem

Page 106: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Pascal’s Triangle

Pascal’s Triangle contains many patterns and relations.

Permutations, Combinations and the Binomial Theorem

Page 107: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

A Sample of Combinatorial Identies

There are literally thousands of combinatorial identities basedon the binomial coefficients. We shall look at a small sample.

1n∑

i=0

(ni

)= 2n

(or the number of distinct subsets of an n-set is 2n).

2

b n2 c∑

i=1

(n2i

)=

b n2 c∑

i=1

(n

2i − 1

)(or the number of ditinct subsets of even order is equal tothe number of subset of odd order). Proof: (1− 1)n = 0.

Permutations, Combinations and the Binomial Theorem

Page 108: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

A Sample of Combinatorial Identies

There are literally thousands of combinatorial identities basedon the binomial coefficients. We shall look at a small sample.

1n∑

i=0

(ni

)= 2n

(or the number of distinct subsets of an n-set is 2n).2

b n2 c∑

i=1

(n2i

)=

b n2 c∑

i=1

(n

2i − 1

)(or the number of ditinct subsets of even order is equal tothe number of subset of odd order). Proof: (1− 1)n = 0.

Permutations, Combinations and the Binomial Theorem

Page 109: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 (2nn

)=

n∑i=0

(ni

)2

Proof: (2nn

)=

n∑i=0

(ni

)(n

n − i

)Both sides count the number of ways to select a team of nstudents from a class with n male students and n females.

2 Vandermonde’s Identity:(n + m

r

)=

r∑k=0

(nk

)(m

r − k

)3

r∑k=0

(n + k

r

)=

(n + r + 1

r

)

Permutations, Combinations and the Binomial Theorem

Page 110: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 (2nn

)=

n∑i=0

(ni

)2

Proof: (2nn

)=

n∑i=0

(ni

)(n

n − i

)Both sides count the number of ways to select a team of nstudents from a class with n male students and n females.

2 Vandermonde’s Identity:(n + m

r

)=

r∑k=0

(nk

)(m

r − k

)3

r∑k=0

(n + k

r

)=

(n + r + 1

r

)

Permutations, Combinations and the Binomial Theorem

Page 111: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 (2nn

)=

n∑i=0

(ni

)2

Proof: (2nn

)=

n∑i=0

(ni

)(n

n − i

)Both sides count the number of ways to select a team of nstudents from a class with n male students and n females.

2 Vandermonde’s Identity:(n + m

r

)=

r∑k=0

(nk

)(m

r − k

)

3r∑

k=0

(n + k

r

)=

(n + r + 1

r

)

Permutations, Combinations and the Binomial Theorem

Page 112: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

1 (2nn

)=

n∑i=0

(ni

)2

Proof: (2nn

)=

n∑i=0

(ni

)(n

n − i

)Both sides count the number of ways to select a team of nstudents from a class with n male students and n females.

2 Vandermonde’s Identity:(n + m

r

)=

r∑k=0

(nk

)(m

r − k

)3

r∑k=0

(n + k

r

)=

(n + r + 1

r

)

Permutations, Combinations and the Binomial Theorem

Page 113: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

A tribute to Gauss

QuestionAn urn contains 100 balls numbered 1,2, . . . ,100. 100 personsdraw a ball, note the number on it and return it to the urn. Whatis the probability that no two persons draw the same ball?

Answer

There are 100100 different ways to draw 100 balls. There areonly 100! ways to draw different balls. So the probability that notwo persons will draw the same ball is 100!

100100 . So we need toestimate this number.

Permutations, Combinations and the Binomial Theorem

Page 114: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

A tribute to Gauss

QuestionAn urn contains 100 balls numbered 1,2, . . . ,100. 100 personsdraw a ball, note the number on it and return it to the urn. Whatis the probability that no two persons draw the same ball?

Answer

There are 100100 different ways to draw 100 balls. There areonly 100! ways to draw different balls. So the probability that notwo persons will draw the same ball is 100!

100100 . So we need toestimate this number.

Permutations, Combinations and the Binomial Theorem

Page 115: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Estimates

1 Simplest estimates:

n! =n∏

i=1

i ≤n∏

i=1

n = nn n! =n∏

i=1

i ≥n∏

i=1

2 = 2n

2 Slightly better estimates:

n! ≥n∏

i=n/2

i ≥n∏

i=n/2

n/2 =(n

2

) n2 n! ≤

( n/2∏i=1

n2

)( n∏i=n/2

n)

=nn

2n2

RemarkSo the probability that each person will see a different numberis < 2−50 or just about no chance!

Even though it looks as if the estimates assume that n is even,it is not difficult to show that they hold for odd n.

Permutations, Combinations and the Binomial Theorem

Page 116: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Estimates

1 Simplest estimates:

n! =n∏

i=1

i ≤n∏

i=1

n = nn n! =n∏

i=1

i ≥n∏

i=1

2 = 2n

2 Slightly better estimates:

n! ≥n∏

i=n/2

i ≥n∏

i=n/2

n/2 =(n

2

) n2 n! ≤

( n/2∏i=1

n2

)( n∏i=n/2

n)

=nn

2n2

RemarkSo the probability that each person will see a different numberis < 2−50 or just about no chance!

Even though it looks as if the estimates assume that n is even,it is not difficult to show that they hold for odd n.

Permutations, Combinations and the Binomial Theorem

Page 117: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Estimates

1 Simplest estimates:

n! =n∏

i=1

i ≤n∏

i=1

n = nn n! =n∏

i=1

i ≥n∏

i=1

2 = 2n

2 Slightly better estimates:

n! ≥n∏

i=n/2

i ≥n∏

i=n/2

n/2 =(n

2

) n2 n! ≤

( n/2∏i=1

n2

)( n∏i=n/2

n)

=nn

2n2

RemarkSo the probability that each person will see a different numberis < 2−50 or just about no chance!

Even though it looks as if the estimates assume that n is even,it is not difficult to show that they hold for odd n.

Permutations, Combinations and the Binomial Theorem

Page 118: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Gauss’ nice estimates

Theorem (Gauss)

nn2 ≤ n! ≤

(n + 12)n

Proof.

n∏i=1

i =n∏

i=1

(n + 1− i) = n!⇒ n! =

√√√√ n∏i=1

i(n + 1− i)

By the geometric-arithmetic inequality√

i(n + 1− i) ≤(n+1

2

)so

n! ≤n∏

i=1

n + 12

=(n + 1

2)n

i(n + 1− i) ≥ n⇒ n! ≥√

nn

Permutations, Combinations and the Binomial Theorem

Page 119: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Gauss’ nice estimates

Theorem (Gauss)

nn2 ≤ n! ≤

(n + 12)n

Proof.

n∏i=1

i =n∏

i=1

(n + 1− i) = n!⇒ n! =

√√√√ n∏i=1

i(n + 1− i)

By the geometric-arithmetic inequality√

i(n + 1− i) ≤(n+1

2

)so

n! ≤n∏

i=1

n + 12

=(n + 1

2)n

i(n + 1− i) ≥ n⇒ n! ≥√

nn

Permutations, Combinations and the Binomial Theorem

Page 120: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Gauss’ nice estimates

Theorem (Gauss)

nn2 ≤ n! ≤

(n + 12)n

Proof.

n∏i=1

i =n∏

i=1

(n + 1− i) = n!⇒ n! =

√√√√ n∏i=1

i(n + 1− i)

By the geometric-arithmetic inequality√

i(n + 1− i) ≤(n+1

2

)so

n! ≤n∏

i=1

n + 12

=(n + 1

2)n

i(n + 1− i) ≥ n⇒ n! ≥√

nn

Permutations, Combinations and the Binomial Theorem

Page 121: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Gauss’ nice estimates

Theorem (Gauss)

nn2 ≤ n! ≤

(n + 12)n

Proof.

n∏i=1

i =n∏

i=1

(n + 1− i) = n!⇒ n! =

√√√√ n∏i=1

i(n + 1− i)

By the geometric-arithmetic inequality√

i(n + 1− i) ≤(n+1

2

)so

n! ≤n∏

i=1

n + 12

=(n + 1

2)n

i(n + 1− i) ≥ n⇒ n! ≥√

nn

Permutations, Combinations and the Binomial Theorem

Page 122: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

Gauss’ nice estimates

Theorem (Gauss)

nn2 ≤ n! ≤

(n + 12)n

Proof.

n∏i=1

i =n∏

i=1

(n + 1− i) = n!⇒ n! =

√√√√ n∏i=1

i(n + 1− i)

By the geometric-arithmetic inequality√

i(n + 1− i) ≤(n+1

2

)so

n! ≤n∏

i=1

n + 12

=(n + 1

2)n

i(n + 1− i) ≥ n⇒ n! ≥√

nn

Permutations, Combinations and the Binomial Theorem

Page 123: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

We conclude by mentioning a very famous and beautifulapproximation: Stirling’s Formula.It uses two of the most famous constants in mathematics: πand e in one expression involving an approximation of theinteger valued function n!.

n! ∼√

2πnn+ 12 e−n

For a proof of this formula see the file Stirling.pdf.

In manyapplications, for example in combinatorial probability, factorialsand binomial coefficients are very ubiquitous. Stirling’s formulaprovides an excellent approximation using a much easierexpression to manipulate. For instance, how big is 100!?Using Stirling’s formula we get:

lg 100! ≈ 100 lg(100e

) + 1 + lg√

2π = 157.96 . . .

The actual number of digits of 100! is 158.20pt

(2nn

)∼ 4n√

2πIs another useful approximation.

Permutations, Combinations and the Binomial Theorem

Page 124: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

We conclude by mentioning a very famous and beautifulapproximation: Stirling’s Formula.It uses two of the most famous constants in mathematics: πand e in one expression involving an approximation of theinteger valued function n!.

n! ∼√

2πnn+ 12 e−n

For a proof of this formula see the file Stirling.pdf. In manyapplications, for example in combinatorial probability, factorialsand binomial coefficients are very ubiquitous. Stirling’s formulaprovides an excellent approximation using a much easierexpression to manipulate. For instance, how big is 100!?

Using Stirling’s formula we get:

lg 100! ≈ 100 lg(100e

) + 1 + lg√

2π = 157.96 . . .

The actual number of digits of 100! is 158.20pt

(2nn

)∼ 4n√

2πIs another useful approximation.

Permutations, Combinations and the Binomial Theorem

Page 125: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

We conclude by mentioning a very famous and beautifulapproximation: Stirling’s Formula.It uses two of the most famous constants in mathematics: πand e in one expression involving an approximation of theinteger valued function n!.

n! ∼√

2πnn+ 12 e−n

For a proof of this formula see the file Stirling.pdf. In manyapplications, for example in combinatorial probability, factorialsand binomial coefficients are very ubiquitous. Stirling’s formulaprovides an excellent approximation using a much easierexpression to manipulate. For instance, how big is 100!?Using Stirling’s formula we get:

lg 100! ≈ 100 lg(100e

) + 1 + lg√

2π = 157.96 . . .

The actual number of digits of 100! is 158.

20pt(2n

n

)∼ 4n√

2πIs another useful approximation.

Permutations, Combinations and the Binomial Theorem

Page 126: Permutations, Combinations and the Binomial TheoremPermutations, Combinations and the Binomial Theorem November 24, 2010 Permutations, Combinations and the Binomial Theorem. Permutation,

We conclude by mentioning a very famous and beautifulapproximation: Stirling’s Formula.It uses two of the most famous constants in mathematics: πand e in one expression involving an approximation of theinteger valued function n!.

n! ∼√

2πnn+ 12 e−n

For a proof of this formula see the file Stirling.pdf. In manyapplications, for example in combinatorial probability, factorialsand binomial coefficients are very ubiquitous. Stirling’s formulaprovides an excellent approximation using a much easierexpression to manipulate. For instance, how big is 100!?Using Stirling’s formula we get:

lg 100! ≈ 100 lg(100e

) + 1 + lg√

2π = 157.96 . . .

The actual number of digits of 100! is 158.20pt

(2nn

)∼ 4n√

2πIs another useful approximation.

Permutations, Combinations and the Binomial Theorem