ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Find triplet sum in BST Problem Statement: You are given a BST node and a key. YOu need to find if that key exist any triplet sum in given BST. Solution We do…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Convert sorted DLL to Balanced BST Problem Statement: You are given an DLL where the nodes are sorted in ascending order. we need to construct Balanced BST in-place. In-place…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Count the number of BST nodes that lie in a given range. Solution The solution is very simple. For every node visited, check if the node lies in range, if yes, then increment the count. Then…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Get the Shortest distance between two nodes in BST Problem Statement: You are given the root node of BST and 2 key elements. You need to find the distance between the 2 nodes. Solution So as…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Return the sum of given range in BST. Problem Statement: You are given a root of BST and 2 values. You need to return the sum of the nodes that falls within the range. Solution For…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Kth smallest Element in a BST Problem Statement: You are given BST and a kth element in the given tree. Then you need to give the kth smallest element. Solution Solution is…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Kth Largest Element in a BST Problem Statement: You are given BST and a kth element in the given tree. Then you need to give the kth largest element. Solution Here we need…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Merge Two balanced BST Problem Statement: You are given two balanced BST, you need to merge the two given balanced BST. Solution THe solution is very simple. WKT…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Convert a normal BST into a Balanced BST Problem Statement: You are given a BST root node, you need to make it as a balanced BST. Example Input: 3 / 2 / 1 Output: 2 / \ 1 3 Solution…
ProDeveloperTutorialonJanuary 19, 2025 Binary Search Trees: Convert Binary Tree into Binary Search Tree. Example Input: 11 / \ 3 8 / \ 9 5 Output: 9 / \ 5 11 / \ 3 8 Solution The solution is simple: 1. Take the node values into an temp array by…