Count the number of Binary Tree possible for a given Preorder Sequence length n. Input : n = 1 Output : 1 Input : n… Read More »
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 »
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 »
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 »
Given an array that represents Inorder Traversal, find all possible Binary Trees with the given Inorder traversal and print their preorder traversals.
A succinct encoding of Binary Tree takes close to minimum possible space. The number of structurally different binary trees on n nodes is n’th Catalan… Read More »
In this article, first count of possible BST (Binary Search Trees)s is discussed, then construction of all possible BSTs. How many structurally unique BSTs for… Read More »
Given a number n find the number of valid parentheses expressions of that length.
Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following.
The number of structurally different Binary Trees with n nodes is Catalan number Cn = (2n)!/(n+1)!*n!
Total number of possible Binary Search Trees with n different keys = Catalan number Cn = (2n)!/(n+1)!*n!