Combinatorial mathematics and its application--Cattleya number

Source: Internet
Author: User

Cattleya number is a common and important special counting formula in combinatorial mathematics.

First, give a realistic model of the problem:

The number of edges of convex polygon is given, and the method to divide the area into triangular area is solved by solving the disjoint diagonal line of the convex polygon.

First we conduct a preliminary analysis, when N=2,h2=1, that is, for triangles, the number of cases divided is 1. This seems a bit difficult to understand, because the triangle inside cannot add diagonal, so the case is the triangle itself, the number of cases is 1.

Let's discuss the case where n takes any value.

Look at the picture below.

Consider the n+1 convex edge of the sub-problem, that is, we think of AB as the base edge, the position of the enumeration C, there are n-1 enumerable position, and then combined with the basic counting principle, we can see that the following recursion can not be heavy without leakage of the expression h[n].

And now the problem is that this recursive formula is what we do not like, we prefer the form of Fibonacci sequence, given the relationship between the front and back and then we can find the linear time complexity of the sequence, then we need to discuss how to get this recursive formula solution.

Here is the Java code that calculates the Cattleya sequence based on this conclusion:

ImportJava.io.*;ImportJava.util.*;ImportJava.math.BigInteger; Public classmain{ Public Static voidMain (String args[]) {biginteger[] a=NewBiginteger[101]; a[0] =Biginteger.zero; a[1] = biginteger.valueof (1);  for(inti = 2; I <= 100; ++i) a[i]= A[i-1].multiply (biginteger.valueof (4 * i-2)). Divide (Biginteger.valueof (i+1)); Scanner in=NewScanner (system.in); intN;  while(In.hasnext ()) {n=In.nextint ();   System.out.println (A[n]); } }}

Combinatorial mathematics and its application--Cattleya number

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.