## Merge Two Balanced Binary Search Trees

You are given two balanced binary search trees e.g., AVL or Red Black Tree. Write a function that merges the two given balanced BSTs into… Read More »

## AVL Tree | Set 1 (Insertion)

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for… Read More »

## Find the largest BST subtree in a given Binary Tree | Set 1

Given a Binary Tree, write a function that returns the size of the largest subtree which is also a Binary Search Tree (BST). If the… Read More »

## Sorted Array to Balanced BST

Given a sorted array. Write a function that creates a Balanced Binary Search Tree using array elements. Examples: Input: Array {1, 2, 3} Output: A… Read More »

## Sorted Linked List to Balanced BST

Given a Singly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as… Read More »

## Print BST keys in the given range

Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Print all the keys of tree… Read More »

## Find k-th smallest element in BST (Order Statistics in BST)

Given root of binary search tree and K as input, find K-th smallest element in BST. For example, in the following BST, if k =… Read More »

## Inorder Successor in Binary Search Tree

In Binary Tree, Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the… Read More »

## Sorted order printing of a given array that represents a BST

Given an array that stores a complete Binary Search Tree, write a function that efficiently prints the given array in ascending order. For example, given… Read More »

## Total number of possible Binary Search Trees and Binary Trees with n keys

Total number of possible Binary Search Trees with n different keys (countBST(n)) = Catalan number Cn = (2n)! / ((n + 1)! * n!) For… Read More »

## A program to check if a binary tree is BST or not

A binary search tree (BST) is a node based binary tree data structure which has the following properties. • The left subtree of a node… Read More »

## Find the node with minimum value in a Binary Search Tree

This is quite simple. Just traverse the node from root to left recursively until left is NULL. The node whose left is NULL is the… Read More »

## Lowest Common Ancestor in a Binary Search Tree.

Given values of two values n1 and n2 in a Binary Search Tree, find the Lowest Common Ancestor (LCA). You may assume that both the… Read More »