当前位置:网站首页>[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
2022-07-03 18:30:00 【Programmer community】
List of articles
- One 、 Wrong way
- Two 、 Derivation of recurrence formula for staggered arrangement problem
- 3、 ... and 、 Derive the staggered formula
One 、 Wrong way
n
n
n A different letter And
n
n
n Different envelopes , take
n
n
n The number of schemes with wrong envelopes in each letter ;
Dislocation ( Derangement ) , Therefore, we use
D
(
n
)
D(n)
D(n) Express
n
n
n Staggered arrangement of elements ;
If there is
1
1
1 letter ,
n
=
1
n= 1
n=1 , At this time, it is not allowed to arrange wrongly ,
D
(
1
)
=
0
D(1) = 0
D(1)=0 ;
If there is
2
2
2 letter ,
n
=
2
n= 2
n=2 , At this time, the wrong arrangement can be completed by exchanging , Yes
1
1
1 Kind of plan ,
D
(
2
)
=
1
D(2) = 1
D(2)=1 ;

If there is
3
3
3 letter ,
1
,
2
,
3
1,2,3
1,2,3 Three letters and three envelopes ,
- If
1
1
1 Put it in
3
3
3 In the envelope , At this time will be
2
2
2 Put it in
1
1
1 In the envelope , take
3
3
3 Put it in
2
2
2 In the envelope ,
1
,
2
,
3
1,2,3
1,2,3
3
,
1
,
2
3,1,2
3,1,2
- If
1
1
1 Put it in
2
2
2 In the envelope , At this time will be
2
2
2 Put it in
3
3
3 In the envelope , take
3
3
3 Put it in
1
1
1 In the envelope ,
1
,
2
,
3
1,2,3
1,2,3
2
,
3
,
1
2,3,1
2,3,1
D
(
3
)
=
2
D(3) = 2
D(3)=2
If there is
4
4
4 letter , At this time, it is difficult to calculate ,
9
9
9 Methods ,
D
(
4
)
=
9
D(4) = 9
D(4)=9
If there is
5
5
5 letter
⋯
\cdots
⋯ ,
D
(
5
)
=
44
D(5) = 44
D(5)=44
⋮
\vdots
⋮
If there is
n
n
n letter
⋯
\cdots
⋯ ,
D
(
n
)
=
n
!
(
(
−
1
)
0
0
!
+
(
−
1
)
1
1
!
+
(
−
1
)
2
2
!
+
(
−
1
)
3
3
!
+
⋯
+
(
−
1
)
n
n
!
)
=
n
!
∑
k
=
0
n
(
−
1
)
k
k
!
D(n) = n! ( \cfrac{(-1)^0}{0!} + \cfrac{(-1)^1}{1!} + \cfrac{(-1)^2}{2!} + \cfrac{(-1)^3}{3!} + \cdots + \cfrac{(-1)^n}{n!} ) = n! \sum\limits_{k=0}^{n}\cfrac{(-1)^k}{k!}
D(n)=n!(0!(−1)0+1!(−1)1+2!(−1)2+3!(−1)3+⋯+n!(−1)n)=n!k=0∑nk!(−1)k
Two 、 Derivation of recurrence formula for staggered arrangement problem
Observe the above rules , Derive the recurrence formula ;
If there is
n
n
n letter , Any letter needs to be misplaced , The number of staggered schemes is
D
(
n
)
D(n)
D(n) ;
1 . Step by step counting principle : Use Step by step counting principle , Statistics first The arrangement of the first letter , And then we'll talk about it The number of arrangement methods of other letters ;
( 1 ) First step : First find a letter
a
a
a come out , This letter cannot be placed in its own place , Can only be placed in the rest
n
−
1
n-1
n−1 In a position , So there is
n
−
1
n-1
n−1 To arrange ;
( 2 ) The second step : Now let's talk about the rest except
a
a
a The wrong arrangement of the position of other letters except ;
2 . Classification and counting principle
Suppose the first letter
a
a
a Occupy
b
b
b The location of , So at this time
b
b
b There are two ways to put it in which envelope ,
b
b
b Put it in
a
a
a Location , or
b
b
b Not put in
a
a
a Location ;
( 1 ) The first category : The first is to put
a
a
a Location , here
b
b
b Put it in
a
a
a Location , be left over
n
−
2
n-2
n−2 The letter is wrongly arranged , The number of options is
D
(
n
−
2
)
D(n-2)
D(n−2)
( 2 ) The second category : The second situation is
b
b
b I didn't go
a
a
a The location of , that
b
b
b May appear in addition to
a
a
a Anywhere except ,
b
b
b Yes
n
−
2
n-2
n−2 There are four places to go , Can't go to
a
,
b
a,b
a,b Location , All other elements have
n
−
2
n-2
n−2 There are four places to go (
a
,
b
a,b
a,b Position cannot go ) , In this case It's equivalent to dividing
a
a
a The wrong arrangement of other elements besides , namely
n
−
1
n-1
n−1 Dislocation of elements , The number of options is
D
(
n
−
1
)
D(n-1)
D(n−1) ; * ( Core derivation logic ) *
( 3 ) The law of addition : Summarize the above classification and counting principles , Use The law of addition , The result is
D
(
n
−
1
)
+
D
(
n
−
2
)
D(n -1) + D(n-2)
D(n−1)+D(n−2)
3 . product rule : Summarize the above step-by-step counting principle , Use product rule , The result is
D
(
n
)
=
(
n
−
1
)
(
D
(
n
−
1
)
+
D
(
n
−
2
)
)
D(n) = (n-1) (D(n -1) + D(n-2))
D(n)=(n−1)(D(n−1)+D(n−2))
3、 ... and 、 Derive the staggered formula
The recursive formula :
D
(
n
)
=
(
n
−
1
)
(
D
(
n
−
1
)
+
D
(
n
−
2
)
)
D(n) = (n-1) (D(n -1) + D(n-2))
D(n)=(n−1)(D(n−1)+D(n−2))
initial value :
D
(
1
)
=
0
,
D
(
2
)
=
1
D(1) = 0 , D(2) = 1
D(1)=0,D(2)=1
Use Recurrence equation , Generating functions to solve recursive equations , Principle of tolerance and exclusion , The following formula can be derived :
D
(
n
)
=
n
!
(
(
−
1
)
0
0
!
+
(
−
1
)
1
1
!
+
(
−
1
)
2
2
!
+
(
−
1
)
3
3
!
+
⋯
+
(
−
1
)
n
n
!
)
=
n
!
∑
k
=
0
n
(
−
1
)
k
k
!
D(n) = n! ( \cfrac{(-1)^0}{0!} + \cfrac{(-1)^1}{1!} + \cfrac{(-1)^2}{2!} + \cfrac{(-1)^3}{3!} + \cdots + \cfrac{(-1)^n}{n!} ) = n! \sum\limits_{k=0}^{n}\cfrac{(-1)^k}{k!}
D(n)=n!(0!(−1)0+1!(−1)1+2!(−1)2+3!(−1)3+⋯+n!(−1)n)=n!k=0∑nk!(−1)k
Reference resources :
- Baidu Encyclopedia - The staggered formula
- 【 Combinatorial mathematics 】 Recurrence equation ( Summary of the solution process of recursive equations | Homogeneous | Heavy root | Nonhomogeneous | The characteristic root is 1 | Exponential form | The bottom is the exponential form of the characteristic root ) **
- 【 Combinatorial mathematics 】 Generating function ( Generate function application scenarios | Solving recursive equations using generating functions )
- 【 Set theory 】 Principle of tolerance and exclusion ( The inclusion exclusion principle | Example )
边栏推荐
- Computer graduation project PHP library book borrowing management system
- PHP MySQL inserts multiple pieces of data
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
- Win32: analyse du fichier dump pour la défaillance du tas
- Ssl/bio of OpenSSL_ get_ fd
- Class exercises
- How to track the real-time trend of Bank of London
- Summary and Reflection on the third week of winter vacation
- Change the single node of Postgres database into master-slave
- Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
猜你喜欢

Redis core technology and practice - learning notes (11): why not just string

2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report

PHP MySQL inserts multiple pieces of data

Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing

How to quickly view the inheritance methods of existing models in torchvision?

Redis cache avalanche, penetration, breakdown

Opencv learning notes (continuously updated)

Bidding procurement scheme management of Oracle project management system

Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries

MySQL duplicate check
随机推荐
[combinatorics] exponential generating function (example 2 of solving multiple set permutation with exponential generating function)
Computer graduation project PHP library book borrowing management system
English语法_名词 - 分类
On Data Mining
English grammar_ Noun classification
Image 24 bits de profondeur à 8 bits de profondeur
Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing
Theoretical description of linear equations and summary of methods for solving linear equations by eigen
Coordinate layer conversion tool (video)
Sepconv (separable revolution) code recurrence
198. Looting - Dynamic Planning
OpenSSL的SSL/BIO_get_fd
Redis core technology and practice - learning notes (IX): slicing cluster
[untitled]
[combinatorics] generating function (positive integer splitting | unordered | ordered | allowed repetition | not allowed repetition | unordered not repeated splitting | unordered repeated splitting)
Torch learning notes (3) -- univariate linear regression model (self training)
This diversion
Redis core technology and practice - learning notes (VII) sentinel mechanism
Redis on local access server
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)