Skip to content

Category Archives: Binary Search Tree

Given preorder traversal of a binary search tree, construct the BST.For example, if the given traversal is {10, 5, 1, 7, 40, 50}, then the… Read More
Given the preorder traversal of a binary search tree, construct the BST. Examples:  Input: {10, 5, 1, 7, 40, 50}Output:   10         … Read More
Two of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST.  Input: x = 20, y = 8    … Read More
Given Preorder traversal of a BST, check if each non-leaf node has only one child. Assume that the BST contains unique entries. Examples : Input: pre[]… Read More
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 inorder traversal of merged BSTs.  Examples: Input: First BST        3    /     \ 1    … Read More
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 a… Read More
 AVL Tree: AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than… Read More
Largest BST in a Binary Tree | Set 3 Method 3 (Shorter, Smarter and More Efficient)  In this section, a different O(n) solution is discussed.… Read More
Given a sorted array. Write a function that creates a Balanced Binary Search Tree using array elements. Examples:  Input: arr[] = {1, 2, 3}Output: A… Read More
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. The task is to print all… Read More
Given the root of a binary search tree and K as input, find Kth smallest element in BST. For example, in the following BST, if k… Read More
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. For example, given an… Read More

Start Your Coding Journey Now!