# Binary Search Tree

Given a Binary Tree, write code to check if it is Binary Search Tree or not ? Binary search tree is a binary tree with following restrictions All values in the left subtree are Less than the value at root. All values in the Right subtree are Greater than the value at root. Both Left […]

Given a Binary Tree, write code to convert it to Binary Search Tree such that the structure of the tree remains the same. For example: Both the below trees 5 10 / \ / \ 8 10 5 30 / \ \ / \ \ 4 30 1 8 40 1 / / 40 4 […]

In a Binary Search Tree, you are given the values of two nodes. Write a code which will return the Lowest Common Ancestor of both the nodes. For Example: If the BST is as shown on the right and Nodes are 4 and 8, The output should be: 5 4 and 8 has two common […]

Given the PreOrder traversal of a binary search tree (in the form of a tree), check if all the nodes (except the last) of the tree has exactly one child. For Example: If the Preorder traversal of the tree is given as below: {50, 25, 45, 30, 27, 29} The the output should be: TRUE […]

Earlier, we have seen how to find the minimum element in a Binary Search Tree. Write a function which will return the maximum value in a binary search tree. For example: For the below Binary search tree, the function should return 40 Structure of the Node of the Tree is as given below: struct Node […]

Given a Binary Search Tree (BST), where will you find the node containing minimum value in the Tree? For example: If the tree is as given below Then answer is 1. Write a function that returns the least value in given BST.