Combinatorial Mathematics
(TsinghuaX: 60240013x)
Talking about combinatorics
What is combinatorics
The most ingenious arrangement —— Magic Square
幻方按策略对阶数分类:odd-ordered,4m-ordered,4m+2-ordered
- A T-shirt will be printed with a magic square of size 3. How many different prints are possible?
Key: 8
Suffering Parchment Roll
Is your cellphone password safe?
iPhone&Android
Brute-force Enumaration or Abstract conversion
- The World Cup elimination rounds involve 16 teams in straight knockout matches. How many matches must there be before a champion is determined?
Key:15
Hint: 16−1=15 - A large tournament has 569 entrants in total. If it is a single elimination tournament, how many matches have to be played out before the champion can be decided? (Please calculate the precise value)
Key: 568
Seven bridge problem 七桥问题
注:中文介绍可以参考这里
Euler abstracted the original problem into a graph, which he then transformed into a one-stroke problem.
问题抽象&充要条件:The number of odd nodes must either be 0 or 2.
其中,首先保证connected,然后将node按照adjacent edge的条数分为odd node和even node
对于“一笔画”问题的解决方案数目,Euler在论文中提到:对于odd node为0的图,start from any even node,而对于odd node为2的图,则start from any even node and at the end return to it
In the six-bridge problem as shown by the graph below, how many ways are there of traversing all six bridges (shown as edges here) exactly once? (Please calculate the exact figure).
Key: 32
Combinatorial trip of a Pingpang ball
Fundamental Counting Principals
Counting with “+” “-” “*” “/”
4 basic counting principles
Definition of Permutation and combination
Circular Permutation
The number of r- circular permutations of n is P(n,r)r , 2≤r≤n
Necklace
Similar to real necklaces. Based on circular permutation. Here two sides of the necklace are considered a same permutation.
The number of necklace permutation of picking r elements from n is
P(n,r)2r,3≤r≤n
Permutations, Combinations
Generating Algorithms
Donald Knuth. The Art of Computer Programming, Volume 4: Generating
All Tuples and Permutations, Fascicle 2 first printing.
Addison-Wesley, 2005.
Idea of recursion
Generate permutations of
{1,2...n}
with permutations of
{1,2,...n−1}
Lexicographic Order
- Digits have moving directions.
- Exchange two adjacent digits each time.
- Exchange the largest mobile integer.
Mobile Integer
Every digit in
1,2,...,n
has a moving direction.
- If the adjacent digit in the direction of the digit is smaller, it’s a mobile integer.
- 1 is always immobile.
Except when direct to the outside of the sequence,
n is a mobile integer.- Move the largest mobile integer.
- After moving a digit, change directions of all larger numbers to make them mobile again.
Steinhaus–Johnson–Trotter algorithm
Begin with
1⟶
,
2⟶
, …,
n⟶
While there exists a mobile integer, do
1. find the largest mobile integer
m
.
2. switch m and the adjacent integer its arrow points to.
3. switch the direction of all integers
Tools
- Stirling’s Formula
- 使用STL的next_permutation函数生成全排列(C++)
Like A Function But Not A Function
For sequence
c0,c1,c2...,G(x)=c0+c1x+c2x2+...
Function
G(x)
is the generating function for
c0,c1,c2...
Generating Function is mother,counting sequence is a child.
Mapping Relationship
Generating function is a line of hangers which used to display a series of number sequences.
—— Herbert · Vere
Found the mapping relationship is a “Mathematic Discovery”.
Finding mapping is an important mathematic thinking.
If there is 1, 2, 4, 8, 16, 32g of weights each, how different weight can be weighed? How many possible solutions?
G(x)=(1+x)(1+x2)(1+x4)(1+x8)(1+x16)(1+x32)
=1−x21−x+1−x41−x2+1−x41−x8+1−x81−x16+1−x161−x32+1−x321−x64
=1−x641−x
=1+x+x2+x…+x3
=∑63k=0xk
From the generating function it can be known that these weights can be used to weigh from 1g to 63g of weightage. And, each solution is unique.
This problem can be generalize to prove any decimal number n, can be represented as
n=∑k≥0ak2k,0≤ak≤1,k≥0and it is unique.Integer n is split into the summation of
1,2,3,...,m , and repetition is allowed, get its generating function.
G1(x)=(1+x+x2+…)(x+x2+x4+…)…(1+xm+x2m+…)- If m appeared at least once,how is the generating function?
G2(x)=(1+x+x2+…)(x+x2+x4+…)…(xm+x2m+…)=xm(1−x)(1−x2)…(1−xm)=1(1−x)(1−x2)…(1−xm)−1(1−x)(1−x2)…(1−xm−1)
The above combination meaning: The partition number of integer
n
which is split into the summation of
Integer Partition Number
Algorithm for Big Number Calculation?
(f∗g)[m]=∑f[n]g[m−n]
Related Guess: BSD Guess
Ferrers Diagram
From top to bottom n level of grids,
I
is the number of grids for leveli, when
Ferrers Diagram owns the following characteristics:
1. Each level contains at least 1 grid.
2.
1st
row exchanged with
1st
column,
2nd
row exchanged with
2nd
column.
- The number of ways to partition n into k numbers would be the same to the number of ways to partition n with the largest number of k.
- The partition number of integer n is split into the summation of not more than m numbers, is equaled to n is split with the partition number that is not more than m.
- The partition number of the summation of the partitioning of integer n into different odd numbers, is equaled to the partition number of n is partitioned into the self-conjugated Ferrers Diagram.
Generating Function And Recurrence Relation
Binomial Theorem
Hanoi Problem
Structure of Generating Function
or
Transformed into partial fractional algorithm.
Exercise: Find the total occurrence of even number of 5 in n length of decimal number.
From G(x) obtains sequence {an} . The key is over the bridge between sequence to generating function, and between generating function to sequence.