Q. Program to find the total number of possible Binary Search Trees with n keys.ExplanationIn this program, we need to find out the total number of binary search trees can be constructed with n values. Below diagram shows a possible binary search tree with the key value as 3. So, we can construct a total of five binary search trees. When we choose node 1 as the root node, we get two trees. Similarly, one tree with 2 as root node and two trees when we select 3 as the root node. This approach involves selecting a node recursively as the root node and create possible binary search tree. An easy way to calculate the total number of possible binary search trees are through Catalan number: Algorithm
SolutionPythonOutput: Total number of possible Binary Search Trees with given key: 42 COutput: Total number of possible Binary Search Trees with given key: 42 JAVAOutput: Total number of possible Binary Search Trees with given key: 42 C#Output: Total number of possible Binary Search Trees with given key: 42 PHPOutput: Total number of possible Binary Search Trees with given key: 42
Next TopicPrograms List

DBMS
DS
DAA
OS
C. Network
Compiler D.
Web Tech.
Cyber Sec.
C
C++
Java
.Net
Python
Programs
Control S.