# Tag Archives: catalan

## Count distinct regular bracket sequences which are not N periodic

Given an integer N, the task is to find the number of distinct bracket sequences that can be formed using 2 * N brackets such… Read More »

## Count all possible paths from top left to bottom right of a Matrix without crossing the diagonal

Given an integer N which denotes the size of a matrix, the task is to find the number of possible ways to reach the bottom-right… Read More »

## Count of binary strings of length N having equal count of 0’s and 1’s and count of 1’s ≥ count of 0’s in each prefix substring

Given an integer N, the task is to find the number of possible binary strings of length N with an equal frequency of 0‘s and… Read More »

## Must do Math for Competitive Programming

Competitive Programming (CP) doesn’t typically require to know high-level calculus or some rocket science. But there are some concepts and tricks which are sufficient most… Read More »

## Total number of BSTs using array elements

Prerequisite: Total number of possible Binary Search Trees with n keys Given an array arr[] of N integers. The task is to count the number… Read More »

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

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… Read More »

## Total number of possible Binary Search Trees using Catalan Number

Given an integer N, the task is to count the number of possible Binary Search Trees with N keys. Examples: Input: N = 2 Output:… Read More »

## Minimum changes required to make a Catalan Sequence

Given an array arr[] of N integer elements, the task is to change the minimum number of elements of this array such that it contains… Read More »

## Dyck Words of given length

Given an integer n, the task is to count Dyck words possible of length n. A DYCK word is a word containing only characters ‘X’… Read More »

## Number of Permutations such that no Three Terms forms Increasing Subsequence

Given a number N. The task is to find the number of permutations of 1 to N such that no three terms of the permutation… Read More »

## Number of ways a convex polygon of n+2 sides can split into triangles by connecting vertices

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… Read More »

## Number of Binary Trees for given Preorder Sequence length

Count the number of Binary Tree possible for a given Preorder Sequence length n. Examples: Input : n = 1 Output : 1 Input :… Read More »

## Non-crossing lines to connect points in a circle

Consider a circle with n points on circumference of it where n is even. Count number of ways we can connect these points such that… Read More »

## Dyck path

Consider a n x n grid with indexes of top left corner as (0, 0). Dyck path is a staircase walk from bottom left, i.e.,… Read More »

## Applications of Catalan Numbers

Background : Catalan numbers are defined using below formula: Catalan numbers can also be defined using following recursive formula. The first few Catalan numbers for… Read More »