Given Preorder traversal of a BST, check if each non-leaf node has only one child. Assume that the BST contains unique entries.
Given a Binary Tree, convert it to a Binary Search Tree. The conversion must be done in such a way that keeps the original structure… Read More »
Given two Binary Search Trees(BST), print the elements of both BSTs in sorted form. The expected time complexity is O(m+n)
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 »
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 »
Given a sorted array. Write a function that creates a Balanced Binary Search Tree using array elements.
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 »
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 »
Given root of binary search tree and K as input, find K-th smallest element in BST.
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 »
Given an array that stores a complete Binary Search Tree, write a function that efficiently prints the given array in ascending order.
Total number of possible Binary Search Trees with n different keys = Catalan number Cn = (2n)!/(n+1)!*n!
A binary search tree (BST) is a node based binary tree data structure which has the following properties.
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 »