Deep understanding of Cattleya number and its application _c language

Source: Internet
Author: User
Catalan number, Cattleya number, also known as Katalan, is a series of numbers appearing in combinatorial mathematics that often appear in various counting problems. Named after the Belgian mathematician Eugen Charlie Katalan (1814–1894).
Make h (0) =1,h (1) =1,catalan number satisfy the recursive type: h (n) = h (0) *h (n-1) +h (1) *h (n-2) + ... + h (n-1) H (0) (n>=2)
The Catalan number formula is generally in the form of:

Recurrence Relationship:

It also satisfies


This provides a quicker way to compute the number of Katalan.

Cattleya number of the application of n elements in the stack, the order of how many kinds of stack ? This issue is a Cattleya number problem, the process of proving the following:

So that 1 represents the stack, 0 represents the stack, you can convert to a 2n bit, containing n 1,n 0 binary number, to meet from left to right to scan to any one, after the 0 number of not more than 1. There is obviously a total of n 1,n 0 2n bit binary number, the following consider the number that does not meet the requirements.

Consider a 2n-bit binary number with n 1,n 0, and m+1 0 and m when scanned onto the 2m+1 bit 1 (It is easy to prove that this is the case), then the following 0-1 permutations must have n-m 1 and n-m-1 0. When the 2m+2 and its subsequent portion of 0 becomes 1, 1 becomes 0, the binary number corresponding to a n+1 0 and n-1 1.

Conversely, any 2n-bit binary number consisting of n+1 0 and N-1 1, because 0 is 2 and 2n is even, it is necessary to have a cumulative number of 0 on an odd digit number over 1. Also in the back part 0 and 1 interchange, make it by n 0 and N 1 2n digits, that is, n+1 0 and n-1 1 composed of 2n digits must correspond to a number that does not meet the requirements.
Thus the undesirable 2n digits correspond to the arrangement one by one of the n+1 0,n-1 1. Clearly, the number of scenarios that do not meet the requirements is C (2n,n+1).

Thereby . Certificate of Completion.

Parentheses problem such as matrix chain multiplication: P=a1xa2xa3x......xan, according to the multiplication binding law, do not change its order, only in parentheses to represent the product of the pair, how many kinds of parentheses? (H (N) species)

Out Stack order problem  
1, a stack (infinity) into the stack sequence for 1,2,3,.. N, how many different stack sequences are there?
2, there are 2n individual line into the theater. The admission fee is 5 yuan. Only N of them have a 5-dollar bill, the other N people only 10 yuan banknotes, the theater has no other banknotes, asked how many of the methods so as long as there are 10 yuan people buy tickets, the ticket office has 5 yuan notes change? (will hold 5 yuan to see as will be 5 yuan into the stack, holding 10 yuan to view as a stack of 5 yuan out of the stack).

Dividing a multilateral line into a triangular problem  
1, the number of methods to divide a convex polygon region into a triangular region?
2. A lawyer in a big city works in n blocks and n blocks to the north of her place of residence. She walks 2n blocks to work every day. If she never crosses (but can touch) the diagonal from home to office, how many possible paths are there?
3. Select the 2n points on the circle, and connect the dots into pairs so that the resulting n segments do not intersect the number of methods?

How many different two-fork trees can be formed by giving the top node a two-tree problem given n nodes?


Some pen questions
1, 16 people in order to buy sesame cake, of which 8 people have only one 5 yuan per person, the other 8 people have only one 10 dollars per person. 5 pieces of sesame cake A, at the beginning, the owner of the cake shop has no money. 16 customers do not ventilate each other and only buy one per person. Ask the 16 people how many permutations are available to avoid the need to open money.
H (8) =16!/(8!*9!) =1430, so the total number =h (8) *8! *8! =16!/9
2, in the library a total of 6 people in line, 3 also "interview Treasure" a book, 3 in Borrow "Interview Treasure" a book, the library at this time did not have the interview treasure, ask them the number of queues?
H (3) =6!/(3!*4!) =5, so total =h (3) *3!*3!=180

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.