The formula for the error is F (n) = (n-1) (f (n-1) + f (n-2 )) however, let's analyze this question a little. It's like an example of placing a letter in a different mailbox. Let's first consider the first n-1 situation 1. n-1-1 letters are wrong. When we consider n letters, we only need to associate the n-th letter with any of the first n-1 letters.
The result is (n-1) * F (n-1) 2. then, consider that the first n-1 has not been completely misplaced. To add the n-th envelope and exchange it with one of them
In order to realize n letters all put wrong, then it is necessary to have among the first n-1 and only one letter is put correctly, that is to say that the first n-2 is
Put the wrong, that is, F (n-2), and then it is obvious, just need to exchange the N letter with the correct one, and that
A correct letter has n-1 different selection methods, so the result is (n-1) * F (n-2)
Recursive questions all the rows of N tickets may naturally be ann = n! The problem is that N tickets are incorrectly arranged in several ways. First of all, we consider, if the N-1 in front of the individual to take their own tickets, that is, the former N-1 personal meet the wrong row, now come another person, he
You have your own ticket in your hand. As long as he exchanges his tickets with any of the other N-1 individuals, he can satisfy n people's wrong arrangements. There is a way of N-1. In addition, we consider that if the former N-1 individual is not satisfied with the wrong row, and the nth person exchanges his ticket with one of them, it will happen to meet the wrong row
. This happened in the original N-1, The N-2 individual satisfied the wrong row, and only one person took his own ticket, and the N person happened to be with him
After an exchange, the system was able to handle the error. Because of the previous N-1, everyone had the opportunity to take their tickets. So there is a possibility of N-1 exchange. To sum up, F (n) = (I-1) * [F (n-1) + f (n-2)]
Recursive Method derivation of the error sorting Formula
When N numbered elements are placed in N numbered positions, the number of methods that do not correspond to each element number is represented by M (N), then M (n-1) is
It indicates that n-1 Number elements are placed at n-1 numbers, and the number of methods does not correspond to each other, and so on.
Step 1: place the nth element in a single position, such as position K. There are n-1 methods in total;
Step 2: place the element number K. In this case, place it in position N. For N-1 1 elements
Element to the position N, the remaining N-2 element has m (n-2) method; (2) the K element does not put it in the position N, then, for this
N-1 elements, M (n-1) methods;
In summary
M (n) = (n-1) [M (n-2) + M (n-1)]
Original article address: Error row formula stven_king reprint: http://blog.163.com/seeker_forever/blog/static/163238938201042211595207/
Mr. Yan Shu's article "mathematical models and solutions for wrong envelope problems" (see the mathematical Bulletin 2000, 6th, p.35 ), A model and a formula for solving this classic problem are provided:
1, 2 ,......, The n elements of N are arranged in a column. If the sequence numbers of each element are different from their numbers, the column is an incorrect row of n different elements. The total number of error columns for n different elements is F (n ).
F (n) = n! [1-1/1! + 1/2! -1/3! + ...... + (-1) ^ N * 1/N!] (1)
This article will discuss this issue from another perspective.
1. A simple recursive formula
An error line for n different elements can be completed in the following two steps:
Step 1: "error" element 1 (which ranks element 1 at one of the positions from 2nd to N). There is a method of n-1.
Step 2: "error" the remaining n-1 elements are arranged in the following order. Depending on the result of the first step, if element 1 falls into the K position, the second step will first "incorrectly arrange" element K, different la s of k elements will lead to two different situations: (1) k elements are ranked at 1st positions, the N-2 elements left behind are "wrong" in the same position set as their number set. There are f (n-2) methods; (2) the k-th element does not have 1st positions. In this case, the 1st positions can be regarded as the k-th position, which is formed (including the k-th element) the "error" of n-1 elements. There are f (n-1) methods. According to the addition principle, F (n-2) + f (n-1) methods are used to complete the second step.
According to the multiplication principle, the number of wrong sorting of n different elements
F (n) = (n-1) [F (n-2) + f (n-1)] (n> 2 ).
Supplement:
Someone wrote n letters and N envelopes, if all the letters were wrong. Ask how many different situations are there when the wrong envelope is installed for all the messages.
When n = 1 and 2, it is easy to get the solution ~, Assuming that F (N-1) and F (N-2) have been obtained, focus on the analysis of the following situation:
1. When there are n mail, the front N-1 mail can have N-1 or N-2 wrong.
2. The former, for each kind of wrong outfit, can take any one letter from the N-1 Letter and the nth wrong outfit, so = f (N-1) * (N-1 ).
3. The latter is simple, it can only be the letter with no error and the nth letter exchange envelope, the letter without error can be any of the previous N-1 letter
One, so = f (N-2) * (N-1 ).
Basic Form: d [1] = 0; d [2] = 1 recursion: d [N] = (n-1) * (d [n-1] + d [N-2])
This is the famous formula for troubleshooting.
Hangdian 2048 troubleshooting