Cattleya number (Catalan) and its application

Source: Internet
Author: User

Number of Cattleya

Big Guy Blog 8880468

Cattleya number is a series of combinatorial mathematics that often appear in various counting problems.

Cattleya several previous items are: c0=1,c1=1,c2=2,c3=5,c4=14,c5=42,c6=132,c7=429,c8=1430,c9=4862,c10=16796

1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452, 18367353072152, 69533550916004, 263747951750360, 1002242216651368, 3814986502092304, 14544636039226909, 55534064877048198, 212336130412243110, 812944042149730764, 3116285494907301262, 11959798385860453492, 45950804324621742364, ...

Enter an integer n to calculate h (n).

Make h (0) =1,h (1) =1,catalan number meet recursion:h (n) = h (0) *h (n-1) +h (1) *h (n-2) + ... + h (n-1) *h (0) (n>=2)

For example:

H (2) =h (0) *h (1) +h (1) *h (0) =1*1+1*1=2

H (3) =h (0) *h (2) +h (1) *h (1) +h (2) *h (0) =1*2+1*1+2*1=5

Alternative recursion:h (N) =h (n-1) * (4*n-2)/(n+1);

The solution of the recursive relationship is:h (N) =c (2n,n)/(n+1) (n=0,1,2,...)

Alternative solutions for recursive relationships are:h (N) =c (2n,n)-C (2n,n+1) (n=0,1,2,...)

The application of Cattleya number

Application 1: the stack order. A stack (infinity) of the stack sequence is 1,2,3,...,n, how many different out-stack sequences? h (N)

General analysis First of all, we set f (n) = number of the sequence number of the sequence of N of the stack. At the same time, we assume that, from the beginning to the first time the stack is empty, the first stack in this procedure is the ordinal of K. In particular, if the stack is not empty until the end of the process, k=n. The first out-of-stack ordinal k divides the sequence of 1~n into two sequences, one of which is 1~k-1, the number of sequences is k-1, the other is k+1~n, and the sequence number is n-k. At this point, if we think of K as determining an ordinal, then according to the multiplication principle, the problem of f (n) is equivalent to-the number of series of k-1 sequence number of the number of the sequence number is n-k of the stack sequence, that is, select K This ordinal f (n) =f (k-1) XF (n-k). and k can choose 1 to N, so according to the addition principle, k to the different values of the sequence of the sum of the total number of sequences are: F (n) =f (0) F (n-1) +f (1) F (n-2) +......+f (n-1) f (0). See here, and then look at the recursive Cattleya number, the answer is self-evident, that is, f (n) =h (n) = C (2n,n)/(n+1) = C (2n,n)-C (2n,n+1) (n=0,1,2, ...). Finally, make F (0) =1,f (1) = 1.

Unconventional analysis for each number, you must go to the stack once, out of the stack. We set the stack to state ' 1 ' and the stack is set to state ' 0 '. All States of the n number correspond to a 2n binary number consisting of n 1 and N 0. Because the operands waiting for the stack are arranged in the order of 1‥n, the number of operands in the stack is greater than or equal to the operand a (a≤b) of the stack, so the total number of output sequences = the number of binary numbers of 2n bits consisting of n 1 and N 0, and 1 of the cumulative number of the cumulative number not less than 0. In the 2n bit binary number is filled with N 1 scheme number is C (2n,n), do not fill 1 of the remaining n bits are automatically filled 0. The number of scenarios from which non-conforming requirements are subtracted (from left to right scanning, 0 cumulative number greater than 1) is sought. The characteristics of the non-conforming number are scanned by left and right, the cumulative number of m+1 0 and the cumulative number of M 1 must first appear on an odd digit 2m+1 bit, and thereafter 2 (N-M) 1 bits have n-m 1 and n-m-1 0. If the back of this 2 (n-m)-1 bits on the 0 and 1 interchange, so that it becomes n-m 0 and N-m-1 1, the result is 1 by the n+1 0 and N-1 1 is composed of 2n digits, that is, an undesirable number corresponds to a n+1 0 and N-1 1 is composed of an arrangement. In turn, any one consists of n+1 0 and n-1 1 of the binary number of 2n, because 0 of the number of 2, 2n is even, it must be on an odd bit of a 0 cumulative number of more than 1 cumulative number. Also in the following sections 0 and 1 are interchangeable, so that it is made up of n 0 and N 1 composed of 2n digits, that is, n+1 0 and n-1 1 composed of 2n digits must correspond to a non-conforming number. Thus the non-required 2n digits correspond to the permutation one by one composed of n+1 0,n-1 1. Clearly, the number of non-conforming schemes is C (2n,n+1). This results in the total number of output sequences =c (2n,n)-C (2n,n+1) =c (2n,n)/(n+1) =h (n).

Application 2 Description: How many matching methods are there for n pairs of parentheses? H (N)

IDEA: n pairs of parentheses are equivalent to 2n symbols, n left parenthesis, n right parenthesis, can be set to solve the problem of f (2n). The No. 0 symbol is definitely an opening parenthesis, and the closing parenthesis that matches it must be the 2i+1 character. Because if it is the 2i character, then the No. 0 character contains an odd number of characters from the 2i character, and an odd number of characters cannot be matched.

  with simple analysis, f (2n) can be converted to the following recursive f (2n) = f (0) *f (2n-2) + f (2) *f (2n-4) + ... + f (2n-4) *f (2) + f (2n-2) *f (0). To explain briefly, F (0) * F (2n-2) means that the No. 0 character matches the 1th character, while the remaining characters are divided into two parts, a portion of 0 characters, the other part is 2n-2 characters, and the two parts are solved. F (2) *f (2n-4) indicates that the No. 0 character matches the 3rd character, while the remaining characters are divided into two parts, 2 characters in part, and 2n-4 characters in the other part. In turn.         Suppose f (0) = 1, calculate the start of several items, F (2) = 1, f (4) = 2, f (6) = 5. Combined with recursion, it is not difficult to find that f (2n) equals h (n).

Application 3 Description: Matrix chain multiplication: P=a1xa2xa3x......xan, according to the multiplication of the law, do not change its order, only in parentheses to denote the product of the pair, how do you have a few of the bracketed scheme? H (n-1)         ideas: This can be considered, first through the parentheses, the P is divided into two parts, and then the two parts are bracketed. For example, divide (A1) x (A2xa3.....xan) and then bracket (A1) and (A2xa3.....xan) separately, as well as divide (A1XA2) x (A3.....xan) and then bracket (A1XA2) and (A3.....xan).         The number of parenthesized schemes for n matrices is f (n), then the solution for the problem is         f (n) = f (1) *f (n-1) + f (2) *f (n-2) + F (3) *f (n-3) + f (n-1) *f (1). F (1) *f (n-1) is divided into two parts (A1) x (A2xa3.....xan) and then bracketed separately.         calculation begins with a few items, f (1) = 1, f (2) = 1, f (3) = 2, f (4) = 5. Combined with recursion, it is not difficult to find F (n) equals H (n-1). Application 4 Description (same as application 1): a stack (infinity) of the stack sequence is 1,2,3,...,n, how many different out of the stack sequence? h (n)         ideas: This is similar to parentheses, the stack operation is equivalent to an opening parenthesis, The stack operation is the equivalent of a closing parenthesis. The order of the n number and the stack order form a sequence with 2n numbers. The No. 0 number must be the number of the stack, and the number corresponding to the stack must be the number of 2i+1. Because if it is 2i, then the middle contains an odd number of numbers, this odd number will certainly not constitute a stack out of the stack sequence.         The solution for the problem is F (2n), then f (2n) = f (0) *f (2n-2) + f (2) *f (2n-4) + f (2n-2) *f (0). F (0) * F (2n-2) indicates that the No. 0 number is immediately out of the stack, when the number of the stack and out of the stack contains a number of 0, the remainder is the number of 2n-2. F (2) *f (2n-4) indicates that the NO. 0 digital stack and the stack contain 2 digits, equivalent to 1 2 2 1, and the remaining is 2n-4 digits. In turn.         suppose f (0) = 1, calculate the start of several items, F (2) = 1, f (4) = 2, f (6) = 5. Combined with recursion, it is not difficult to find that f (2n) equals h (n).

Application 5 Description: How many situations are there in a two-Tree of n nodes? H (N) thought: It can be considered that the root will definitely occupy a node, then the remaining n-1 nodes can be assigned as follows, T (0, n-1), T (1, n-2),... T (n-1, 0), set T (i, j) to indicate that the left subtree of the root contains I nodes, and the right subtree contains a J node.

The solution of the set problem is f (n), then f (n) = f (0) *f (n-1) + f (1) *f (n-2) + ... + f (n-2) *f (1) + f (n-1) *f (0). Suppose f (0) = 1, then f (1) = 1, f (2) = 2, f (3) = 5. Combined with recursion, it is not difficult to find that f (n) equals h (n).

Application 6 Description: Select 2n points on the circle, align the points together so that the resulting n-segment does not intersect the number of methods? H (N) Idea: Take one of the points as the base point, number 0, and then number the other points in a clockwise direction. Then the number with a number of 0 connected points must be odd, otherwise, the two numbers contain odd points, there is bound to be a point is isolated, that is, on each side of a line segment has an isolated point, resulting in the intersection of two segments. The selected base point is a, and the point to which it is connected is B, so A and B divide all the points into two parts, one on the left side of A and B, and the other on the right side of a and B.        Then the two parts can be solved separately. Set the solution f (n) of the problem, then f (n) = f (0) *f (n-2) + f (2) *f (n-4) + f (4) *f (n-6) + ... f (n-4) *f (2) + f (n-2) *f (0). F (0) *f (n-2) indicates that the point of number 0 is connected to the point of number 1, where the number of points to the right of them is 0, while the point on the left of them is 2n-2.        In turn. F (0) = 1, f (2) = 1, f (4) = 2. Combined with recursion, it is not difficult to find that f (2n) equals h (n).

Application 7 Description: How many ways to divide a convex polygon area into a triangular region? H (n-2) idea: Based on one side of a convex polygon, the 2 vertices of this edge are A and B.       Choose 1 from the remaining vertices, you can divide the convex polygon into three parts, the middle is a triangle, the left and right sides are two convex polygons, and then solve about two convex polygons. Set the solution f (n) of the problem, where n represents the number of vertices, then f (n) = f (2) *f (n-1) + f (3) *f (n-2) + ... f (n-2) *f (3) + f (n-1) *f (2).       F (2) *f (n-1) indicates that three adjacent vertices form a triangle, and the number of vertices in the other two sections is 2 and n-1 respectively. Set F (2) = 1, then f (3) = 1, f (4) = 2, f (5) = 5. Combined with recursion, it is not difficult to find F (n) equals H (n-2). Application 8 Description: There are 2n individuals lined up into the theatre. Admission fee is 5 yuan. of which only n individuals have a 5-dollar bill, the other N people only 10 yuan banknotes, the theater no other banknotes, asked how many of the methods so long as there are 10 of people buy tickets, the ticket office has 5 yuan of money change? H (N) Idea: can hold 5 yuan to buy tickets as the stack, then hold 10 yuan to buy tickets as 5 Yuan out of the stack. This problem translates into the stack order number of stacks. Results are obtained directly from the analysis of application 2, and F (2n) equals h (n).

PS Application 8: Amusement Park Tickets 1 Yuan One, each limited to buy one. Now there are 10 children lined up to buy tickets, of which 5 children each have only 1 yuan a note, the other 5 children each have only 2 Yuan bill one, the conductor did not prepare change. Q: How many queuing methods are there to make the ticket clerk always find the change?

A: Now take 1 Yuan 5 children as the same, take 2 Yuan 5 children also as the same, using our common "dot accumulation method":

Each small section of the figure shows a child with 1 dollars, each small vertical section of the child to take 2 yuan, asked from A to B in the process of any point in the grid is not less than the number of vertical segments: Take 1 yuan to first, and the number of people can not be less than 2 yuan, that is, can not cross the diagonal ab: Each point is the number of points from a to this point. The number of methods to take the method from A to B. By point accumulation can be calculated as 42, that is, Cattleya number c5=42.

And because each child is not the same, so a total of 42x5! x5! =42x120x120=604800 of the situation.

If the problem of 10 people, take 1 yuan 5 people, take 2 yuan 5 people to a total of 2n, take 1 yuan N people, take 2 yuan N people, then the number of queuing methods to meet the requirements are: N!*n!*h (n) =n!*n!*c (2n,n)/(n+1) = (2n)!/(n+1)

Examples of Cattleya numbers:

There are very many combinatorial structures in combinatorial mathematics that can be counted with catalain numbers. In the exercises of Richard P. Stanley's enumerative Combinatorics:volume 21, there are 66 different combinations that can be expressed by catalain numbers. Here are some examples of cn=3 and cn=4: Example 1. CN indicates the number of Dyck word with a length of 2n. Dyck Word is a string of n x and N y, and all prefix strings satisfy the number of x greater than or equal to Y. The following is a length of 6 Dyck words:h (3) =5 xxxyyy xyxxyy xyxyxy xxyyxy xxyxyy Example 2. Replace the x in the previous example with an opening parenthesis, y with a closing parenthesis, and CN for the number of valid expressions that contain the n set of parentheses: H (3) =5 (()) ( CN represents the number of schemes with n nodes that make up different binary trees. The middle n equals 3, the circle represents the node, and the crescent indicates nothing. H (3) =5

Example 4. The CN represents the number of monotonic paths that do not cross the diagonal in the NxN grid point. A monotone path starts at the lower-left corner of the lattice point and ends in the upper-right corner of the lattice point, with each step up or to the right. Calculating the number of such paths is equivalent to calculating the number of Dyck Word: X for "right" and Y for "up". In the case of n = 4: H (4) =14

Similarly: A barrister in a big city works N blocks north of her home and N blocks East. Every day she walks 2n blocks to work. If she never crosses (but can touch) the diagonal from home to the office, how many possible roads are there? H (N)

Example 5. CN represents the number of methods by which the convex polygon of n edges is divided into triangles by connecting vertices. In the case of n=6: H (n-2) =h (4) =14

Example 6. CN indicates the number of methods to fill a ladder-like shape with n rectangles with a height of n. In the case of n = 4: H (4) =14

Example 7. Stack out problem: After dinner, sister washing dishes, sister washed the bowl of the elder sister into a cupboard stacked into a pile. There are a total of n different bowls, before washing is stacked into a pile, perhaps because the little sister to play and make the bowl into the cupboard, the elder sister will wash the bowls in the side, asked: how many kinds of bowls of the little sister can be the way? H (N) a car team on the narrow road, not overtaking, but can enter a dead end to refuel, and then jump in the queue, a total of n cars, ask how many different ways to make the team out of the city? H (N)

Cattleya number (Catalan) and its application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.