Given a convex polygon with n+2 sides. The task is to calculate the number of ways in which triangles can be formed by connecting vertices with non-crossing line segments.
Input: n = 1
It is already a triangle so it can only be formed in 1 way.
Input: n = 2
It can be cut into 2 triangles by using either pair of opposite vertices.
The above problem is an application of a catalan numbers. So, the task is to only find the n’th Catalan Number. First few catalan numbers are 1 1 2 5 14 42 132 429 1430 4862, … (considered from 0th number)
Below is the program to find Nth catalan number:
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Number of ways to arrange 2*N persons on the two sides of a table with X and Y persons on opposite sides
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
- Check if it is possible to create a polygon with given n sides
- Number of ways to split a binary number such that every part is divisible by 2
- Angle between 3 given vertices in a n-sided regular polygon
- Number of triangles after N moves
- Number of triangles that can be formed
- Count the number of possible triangles
- Number of triangles that can be formed with given N points
- Count number of right triangles possible with a given perimeter
- Number of trees whose sum of degrees of all the vertices is L
- Number of triangles possible with given lengths of sticks which are powers of 2
- Number of possible Triangles in a Cartesian coordinate system
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.