**12 people of different height, row in two rows, each row must be from short to high rank, and the second ranking corresponding to the first row of people high, ask how many kinds of arrangement?**
We can analyze the problem from the following aspects:

A. First, the 12 tall and different people in order to increase the height of the sequence into 1 columns, and sequentially from 1 to 12 numbers to simplify the expression of different height;

B. If the order of the first row has been determined, then the arrangement of the second row is naturally determined;

C. Obviously, if there are only 2 persons numbered 1 and 2, there is only one arrangement (1) (2);

D. For each qualifying arrangement numbered 1-n (n is even and assuming the number x at the end of the first row), adding n+1 in the first row and adding n+2 in the second row can produce an arrangement with a qualifying number of 1-(n+2);

E. Under d conditions, the new addition of the first row of n+1 can be replaced with a number **greater than X and less than n+1** (i.e. the number value X ' of the first row of the new end is greater than X and less than or equal to n+1), Because this substitution ensures that the new first row is generated from the original first row (i.e. the first row of the front n/2 is the same arrangement as the original), and adding number n+1 in the second row will make a number in the second row larger (because the n+2 in the second row will not be swapped out). Obviously, no matter which number in the second row is larger, as long as the second row by number increment, will ensure that the original second ranking corresponding to the first row of people high (that is, the number is larger), and the second row at the end of the number n+2 always ensure greater than the first row of the bottom

Therefore, we can draw from the above analysis from the **numbered 1-n** to the **numbered 1-(n+2) arrangement** of the State Conversion tree (n=2,4,6):

The above state transition tree only draws the first row of state transitions, and for the 3rd layer, its n+1=5,n+2=6, apparently n+2, is twice times the value of the node sequence.

So**The number ****of permutations numbered 1-12 is to find the number of nodes in the 6th layer of the tree, and the path from each node from the root node 1 to the 6th level is a first row arrangement (which can be evaluated by the tree traversal algorithm). **For each node we can assign it a number value of order and sequence values as level, the following is a simple way to compute the number of nodes in layer 6th: Java code**Private****void**Firstorder (**int**Order**int**Level) {Place.add (order);**if**(Level >= 6) {count++; Place.pop ();** return**; }** for**(**int**i = order + 1; I < 2 * (level + 1); i++) Firstorder (I, level + 1); Place.pop (); }

private void Firstorder (int order, int level) {
place.add);
if (level >= 6) {
count++;
Place.pop ();
return;
}
for (int i = order + 1; i < 2 * (level + 1); i++)
Firstorder (I, level + 1);
Place.pop ();
}

Here's the complete code to calculate and print the first row: Java code**Import**Java.util.Stack;** Public****class**Twoorderqueue {**Private****int**Count = 0;**Private****int**Total = 0;**Private**stack<integer> Place =**New**Stack<integer> ();** Public**Twoorderqueue (**int**Total) {** This**. Total = Total; }**Private****void**Firstorder (**int**Order**int**Level) {Place.add (order);**if**(Level >= TOTAL/2) {//counting leaf nodes and printing path count++;** for**(Integer i:place) System.out.print (i + ""); System.out.println (); Place.pop ();** return**; //Expand the subtree of the node numbered order and go to the next layer level+1** for**(**int**i = order + 1; I < 2 * (level + 1); i++) Firstorder (I, level + 1); Place.pop (); }** Public****void**Firstorder () {Firstorder (1, 1); System.out.println ("First row a total" + count + "sort arrangement"); }** Public****Static****void**Main (string[] args) {Twoorderqueue q =**New**Twoorderqueue (12); Q.firstorder (); } }

Import Java.util.Stack;
public class Twoorderqueue {
private int count = 0;
private int total = 0;
Private stack<integer> place = new stack<integer> ();
public twoorderqueue (int total) {
this.total = total;
}
private void Firstorder (int order, int level) {
place.add);
if (level >= TOTAL/2) {
//Count leaf node and print path
count++;
for (Integer i:place)
System.out.print (i + "");
System.out.println ();
Place.pop ();
return;
}
Expand the subtree of the node numbered order, and go to the next layer level+1 for
(int i = order + 1; i < 2 * (levels + 1); i++)
Firstorder (I, level + 1);
Place.pop ();
}
public void Firstorder () {
Firstorder (1, 1);
System.out.println ("First row Total" + count + "sort arrangement");
}
public static void Main (string[] args) {
Twoorderqueue q = new Twoorderqueue ();
Q.firstorder ();
}

**Summary:**

We put 12 people of different heights in ascending order of 1 columns, and numbered from 1 to 12, which in addition to simplifying the problem, there are what kind of thinking point of entry. We divided 12 people into 2 columns, which implied an "orderly" approach, that is, if there are 2 empty queues, 12 people choose whether to enter the 1th or 2nd queues, and finally, as long as the number of two teams is the same. Obviously, the order in which these 12 people enter the queue can be arbitrary, so why don't we choose an orderly order. The most obvious order is the order of height increment, the number of them in sequence can not only distinguish between different height, but also to enter the queue sequence, so that the most easily in the process of joining the queue to find the law.

We all know that the **best thing about computers is to use rules to solve the problem of specifications** . For example simplex method, the first step is to standardize the linear equations, and here the best normalization of the problem analysis is a step.

**solve using permutation combinations (see the answers to Benarfa in thinke365 posts):**

If you want to satisfy the request, as long as the selection from 12 people in the first row of 6, then all the positions are determined, because it is required to order by height.

Here's how we choose and what we restrict: 12 people are sorted first from short to high, each person is then selected to the first row or the second row, and if so, if and only after each selection, the number in the second row is not more than the number in the first row, and this condition is arranged in C (12,6)-C ( 12,5) = 132, but this does not get a specific order.