当前位置:网站首页>[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 )
边栏推荐
- 189. Rotation array
- PHP MySQL inserts data
- Torch learning notes (1) -- 19 common ways to create tensor
- Redis core technology and practice - learning notes (VII) sentinel mechanism
- English grammar_ Noun classification
- Grammaire anglaise Nom - Classification
- [combinatorics] generating function (positive integer splitting | unordered non repeated splitting example)
- [enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
- [combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation)
- [combinatorics] generating function (positive integer splitting | basic model of positive integer splitting | disordered splitting with restrictions)
猜你喜欢
How to expand the capacity of golang slice slice
网格图中递增路径的数目[dfs逆向路径+记忆dfs]
2022-2028 global scar care product industry research and trend analysis report
CTO and programmer were both sentenced for losing control of the crawler
Valentine's day, send you a little red flower~
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
Redis core technology and practice - learning notes (VII) sentinel mechanism
PHP MySQL inserts multiple pieces of data
Summary and Reflection on the third week of winter vacation
Module 9 operation
随机推荐
OpenSSL的SSL/BIO_get_fd
CV in transformer learning notes (continuously updated)
网格图中递增路径的数目[dfs逆向路径+记忆dfs]
Have you learned the correct expression posture of programmers on Valentine's day?
Real time split network (continuous update)
Prototype inheritance..
Opencv learning notes (continuously updated)
Setinterval CPU intensive- Is setInterval CPU intensive?
The second largest gay dating website in the world was exposed, and the status of programmers in 2022
4. Load balancing and dynamic static separation
English grammar_ Noun classification
Computer graduation design PHP campus address book telephone number inquiry system
Keepalived setting does not preempt resources
Win32: analyse du fichier dump pour la défaillance du tas
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
2022-2028 global petroleum pipe joint industry research and trend analysis report
The vscode code is automatically modified to a compliance code when it is formatted and saved
[combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
[combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)