VOOZH about

URL: https://www.geeksforgeeks.org/dsa/count-ways-to-divide-circle-using-n-non-intersecting-chord-set-2/

⇱ Count ways to divide circle using N non-intersecting chord | Set-2 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Count ways to divide circle using N non-intersecting chord | Set-2

Last Updated : 12 Jul, 2025

Given a number N. The task is to find the number of ways you can draw N chords in a circle with 2*N points such that no two chords intersect. Two ways are different if there exists a chord that is present in one way and not in other. As the answer could be large print it modulo 10^9+7.

Examples: 

Input : N = 2 
Output :
If points are numbered 1 to 4 in clockwise direction, 
then different ways to draw chords are: 
{(1-2), (3-4)} and {(1-4), (2-3)}

Input :N = 1 
Output :

Approach: 
If we draw a chord between any two points, the current set of points gets broken into two smaller sets S_1 and S_2. If we draw a chord from a point in S_1 to a point in S_2, it will surely intersect the chord we’ve just drawn. So, we can arrive at a recurrence that:

Ways(n) = sum[i = 0 to n-1] { Ways(i)*Ways(n-i-1) }. 
 

The above recurrence relation is similar to the recurrence relation for nth Catalan number which is equal to 2nCn / (n+1). Instead of dividing the numeration with the denomination, multiply the numerator with the modulo inverse of the denominator as division is not allowed in the modulo domain.

Below is the implementation of the above approach:  


Output: 
2

 

Time complexity : O(N*log(mod))

Auxiliary Space: O(1)
 

Comment